Skip to content

Commit

Permalink
Add read-only support to openapiv2
Browse files Browse the repository at this point in the history
  • Loading branch information
hypnoce committed Mar 1, 2019
1 parent 0c2b3b1 commit c1de7cc
Show file tree
Hide file tree
Showing 7 changed files with 155 additions and 140 deletions.
6 changes: 3 additions & 3 deletions internal/stream_chunk.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions protoc-gen-swagger/genswagger/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ func renderMessagesAsDefinition(messages messageMap, d swaggerDefinitionsObject,

// Warning: Make sure not to overwrite any fields already set on the schema type.
schema.ExternalDocs = protoSchema.ExternalDocs
schema.ReadOnly = protoSchema.ReadOnly
schema.MultipleOf = protoSchema.MultipleOf
schema.Maximum = protoSchema.Maximum
schema.ExclusiveMaximum = protoSchema.ExclusiveMaximum
Expand Down Expand Up @@ -1539,6 +1540,7 @@ func protoJSONSchemaToSwaggerSchemaCore(j *swagger_options.JSONSchema, reg *desc
func updateSwaggerObjectFromJSONSchema(s *swaggerSchemaObject, j *swagger_options.JSONSchema) {
s.Title = j.GetTitle()
s.Description = j.GetDescription()
s.ReadOnly = j.GetReadOnly()
s.MultipleOf = j.GetMultipleOf()
s.Maximum = j.GetMaximum()
s.ExclusiveMaximum = j.GetExclusiveMaximum()
Expand Down
2 changes: 2 additions & 0 deletions protoc-gen-swagger/genswagger/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1274,6 +1274,7 @@ func TestRenderMessagesAsDefinition(t *testing.T) {
MaxProperties: 33,
MinProperties: 22,
Required: []string{"req"},
ReadOnly: true,
},
},
},
Expand All @@ -1298,6 +1299,7 @@ func TestRenderMessagesAsDefinition(t *testing.T) {
MaxProperties: 33,
MinProperties: 22,
Required: []string{"req"},
ReadOnly: true,
},
},
},
Expand Down
1 change: 1 addition & 0 deletions protoc-gen-swagger/genswagger/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ type swaggerSchemaObject struct {

ExternalDocs *swaggerExternalDocumentationObject `json:"externalDocs,omitempty"`

ReadOnly bool `json:"readOnly,omitempty"`
MultipleOf float64 `json:"multipleOf,omitempty"`
Maximum float64 `json:"maximum,omitempty"`
ExclusiveMaximum bool `json:"exclusiveMaximum,omitempty"`
Expand Down
4 changes: 2 additions & 2 deletions protoc-gen-swagger/options/annotations.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c1de7cc

Please sign in to comment.