@@ -47,29 +47,29 @@ type Parameter struct {
47
47
48
48
Ref string `json:"$ref,omitempty" yaml:"$ref,omitempty"`
49
49
50
- In string `json:"in,omitempty" yaml:"in,omitempty"`
51
- Name string `json:"name,omitempty" yaml:"name,omitempty"`
52
- Description string `json:"description,omitempty" yaml:"description,omitempty"`
53
- CollectionFormat string `json:"collectionFormat,omitempty" yaml:"collectionFormat,omitempty"`
54
- Type *openapi3.Types `json:"type,omitempty" yaml:"type,omitempty"`
55
- Format string `json:"format,omitempty" yaml:"format,omitempty"`
56
- Pattern string `json:"pattern,omitempty" yaml:"pattern,omitempty"`
57
- AllowEmptyValue bool `json:"allowEmptyValue,omitempty" yaml:"allowEmptyValue,omitempty"`
58
- Required bool `json:"required,omitempty" yaml:"required,omitempty"`
59
- UniqueItems bool `json:"uniqueItems,omitempty" yaml:"uniqueItems,omitempty"`
60
- ExclusiveMin bool `json:"exclusiveMinimum,omitempty" yaml:"exclusiveMinimum,omitempty"`
61
- ExclusiveMax bool `json:"exclusiveMaximum,omitempty" yaml:"exclusiveMaximum,omitempty"`
62
- Schema *openapi3. SchemaRef `json:"schema,omitempty" yaml:"schema,omitempty"`
63
- Items *openapi3. SchemaRef `json:"items,omitempty" yaml:"items,omitempty"`
64
- Enum []any `json:"enum,omitempty" yaml:"enum,omitempty"`
65
- MultipleOf *float64 `json:"multipleOf,omitempty" yaml:"multipleOf,omitempty"`
66
- Minimum *float64 `json:"minimum,omitempty" yaml:"minimum,omitempty"`
67
- Maximum *float64 `json:"maximum,omitempty" yaml:"maximum,omitempty"`
68
- MaxLength *uint64 `json:"maxLength,omitempty" yaml:"maxLength,omitempty"`
69
- MaxItems *uint64 `json:"maxItems,omitempty" yaml:"maxItems,omitempty"`
70
- MinLength uint64 `json:"minLength,omitempty" yaml:"minLength,omitempty"`
71
- MinItems uint64 `json:"minItems,omitempty" yaml:"minItems,omitempty"`
72
- Default any `json:"default,omitempty" yaml:"default,omitempty"`
50
+ In string `json:"in,omitempty" yaml:"in,omitempty"`
51
+ Name string `json:"name,omitempty" yaml:"name,omitempty"`
52
+ Description string `json:"description,omitempty" yaml:"description,omitempty"`
53
+ CollectionFormat string `json:"collectionFormat,omitempty" yaml:"collectionFormat,omitempty"`
54
+ Type *openapi3.Types `json:"type,omitempty" yaml:"type,omitempty"`
55
+ Format string `json:"format,omitempty" yaml:"format,omitempty"`
56
+ Pattern string `json:"pattern,omitempty" yaml:"pattern,omitempty"`
57
+ AllowEmptyValue bool `json:"allowEmptyValue,omitempty" yaml:"allowEmptyValue,omitempty"`
58
+ Required bool `json:"required,omitempty" yaml:"required,omitempty"`
59
+ UniqueItems bool `json:"uniqueItems,omitempty" yaml:"uniqueItems,omitempty"`
60
+ ExclusiveMin bool `json:"exclusiveMinimum,omitempty" yaml:"exclusiveMinimum,omitempty"`
61
+ ExclusiveMax bool `json:"exclusiveMaximum,omitempty" yaml:"exclusiveMaximum,omitempty"`
62
+ Schema *SchemaRef `json:"schema,omitempty" yaml:"schema,omitempty"`
63
+ Items *SchemaRef `json:"items,omitempty" yaml:"items,omitempty"`
64
+ Enum []any `json:"enum,omitempty" yaml:"enum,omitempty"`
65
+ MultipleOf *float64 `json:"multipleOf,omitempty" yaml:"multipleOf,omitempty"`
66
+ Minimum *float64 `json:"minimum,omitempty" yaml:"minimum,omitempty"`
67
+ Maximum *float64 `json:"maximum,omitempty" yaml:"maximum,omitempty"`
68
+ MaxLength *uint64 `json:"maxLength,omitempty" yaml:"maxLength,omitempty"`
69
+ MaxItems *uint64 `json:"maxItems,omitempty" yaml:"maxItems,omitempty"`
70
+ MinLength uint64 `json:"minLength,omitempty" yaml:"minLength,omitempty"`
71
+ MinItems uint64 `json:"minItems,omitempty" yaml:"minItems,omitempty"`
72
+ Default any `json:"default,omitempty" yaml:"default,omitempty"`
73
73
}
74
74
75
75
func (parameter Parameter) MarshalJSON() ([]byte, error)
@@ -113,15 +113,21 @@ func (pathItem *PathItem) SetOperation(method string, operation *Operation)
113
113
func (pathItem *PathItem) UnmarshalJSON(data []byte) error
114
114
UnmarshalJSON sets PathItem to a copy of data.
115
115
116
+ type Ref struct {
117
+ Ref string `json:"$ref" yaml:"$ref"`
118
+ }
119
+ Ref is specified by OpenAPI/Swagger 2.0 standard. See
120
+ https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md#reference-object
121
+
116
122
type Response struct {
117
123
Extensions map[string]any `json:"-" yaml:"-"`
118
124
119
125
Ref string `json:"$ref,omitempty" yaml:"$ref,omitempty"`
120
126
121
- Description string `json:"description,omitempty" yaml:"description,omitempty"`
122
- Schema *openapi3. SchemaRef `json:"schema,omitempty" yaml:"schema,omitempty"`
123
- Headers map[string]*Header `json:"headers,omitempty" yaml:"headers,omitempty"`
124
- Examples map[string]any `json:"examples,omitempty" yaml:"examples,omitempty"`
127
+ Description string `json:"description,omitempty" yaml:"description,omitempty"`
128
+ Schema *SchemaRef `json:"schema,omitempty" yaml:"schema,omitempty"`
129
+ Headers map[string]*Header `json:"headers,omitempty" yaml:"headers,omitempty"`
130
+ Examples map[string]any `json:"examples,omitempty" yaml:"examples,omitempty"`
125
131
}
126
132
127
133
func (response Response) MarshalJSON() ([]byte, error)
@@ -130,6 +136,107 @@ func (response Response) MarshalJSON() ([]byte, error)
130
136
func (response *Response) UnmarshalJSON(data []byte) error
131
137
UnmarshalJSON sets Response to a copy of data.
132
138
139
+ type Schema struct {
140
+ Extensions map[string]any `json:"-" yaml:"-"`
141
+
142
+ AllOf SchemaRefs `json:"allOf,omitempty" yaml:"allOf,omitempty"`
143
+ Not *SchemaRef `json:"not,omitempty" yaml:"not,omitempty"`
144
+ Type *openapi3.Types `json:"type,omitempty" yaml:"type,omitempty"`
145
+ Title string `json:"title,omitempty" yaml:"title,omitempty"`
146
+ Format string `json:"format,omitempty" yaml:"format,omitempty"`
147
+ Description string `json:"description,omitempty" yaml:"description,omitempty"`
148
+ Enum []any `json:"enum,omitempty" yaml:"enum,omitempty"`
149
+ Default any `json:"default,omitempty" yaml:"default,omitempty"`
150
+ Example any `json:"example,omitempty" yaml:"example,omitempty"`
151
+ ExternalDocs *openapi3.ExternalDocs `json:"externalDocs,omitempty" yaml:"externalDocs,omitempty"`
152
+
153
+ // Array-related, here for struct compactness
154
+ UniqueItems bool `json:"uniqueItems,omitempty" yaml:"uniqueItems,omitempty"`
155
+ // Number-related, here for struct compactness
156
+ ExclusiveMin bool `json:"exclusiveMinimum,omitempty" yaml:"exclusiveMinimum,omitempty"`
157
+ ExclusiveMax bool `json:"exclusiveMaximum,omitempty" yaml:"exclusiveMaximum,omitempty"`
158
+ // Properties
159
+ ReadOnly bool `json:"readOnly,omitempty" yaml:"readOnly,omitempty"`
160
+ WriteOnly bool `json:"writeOnly,omitempty" yaml:"writeOnly,omitempty"`
161
+ AllowEmptyValue bool `json:"allowEmptyValue,omitempty" yaml:"allowEmptyValue,omitempty"`
162
+ Deprecated bool `json:"deprecated,omitempty" yaml:"deprecated,omitempty"`
163
+ XML *openapi3.XML `json:"xml,omitempty" yaml:"xml,omitempty"`
164
+
165
+ // Number
166
+ Min *float64 `json:"minimum,omitempty" yaml:"minimum,omitempty"`
167
+ Max *float64 `json:"maximum,omitempty" yaml:"maximum,omitempty"`
168
+ MultipleOf *float64 `json:"multipleOf,omitempty" yaml:"multipleOf,omitempty"`
169
+
170
+ // String
171
+ MinLength uint64 `json:"minLength,omitempty" yaml:"minLength,omitempty"`
172
+ MaxLength *uint64 `json:"maxLength,omitempty" yaml:"maxLength,omitempty"`
173
+ Pattern string `json:"pattern,omitempty" yaml:"pattern,omitempty"`
174
+
175
+ // Array
176
+ MinItems uint64 `json:"minItems,omitempty" yaml:"minItems,omitempty"`
177
+ MaxItems *uint64 `json:"maxItems,omitempty" yaml:"maxItems,omitempty"`
178
+ Items *SchemaRef `json:"items,omitempty" yaml:"items,omitempty"`
179
+
180
+ // Object
181
+ Required []string `json:"required,omitempty" yaml:"required,omitempty"`
182
+ Properties Schemas `json:"properties,omitempty" yaml:"properties,omitempty"`
183
+ MinProps uint64 `json:"minProperties,omitempty" yaml:"minProperties,omitempty"`
184
+ MaxProps *uint64 `json:"maxProperties,omitempty" yaml:"maxProperties,omitempty"`
185
+ AdditionalProperties openapi3.AdditionalProperties `json:"additionalProperties,omitempty" yaml:"additionalProperties,omitempty"`
186
+ Discriminator string `json:"discriminator,omitempty" yaml:"discriminator,omitempty"`
187
+ }
188
+ Schema is specified by OpenAPI/Swagger 2.0 standard. See
189
+ https://swagger.io/specification/v2/#schema-object
190
+
191
+ func (schema Schema) MarshalJSON() ([]byte, error)
192
+ MarshalJSON returns the JSON encoding of Schema.
193
+
194
+ func (schema Schema) MarshalYAML() (any, error)
195
+ MarshalYAML returns the YAML encoding of Schema.
196
+
197
+ func (schema *Schema) UnmarshalJSON(data []byte) error
198
+ UnmarshalJSON sets Schema to a copy of data.
199
+
200
+ type SchemaRef struct {
201
+ // Extensions only captures fields starting with 'x-' as no other fields
202
+ // are allowed by the openapi spec.
203
+ Extensions map[string]any
204
+
205
+ Ref string
206
+ Value *Schema
207
+
208
+ // Has unexported fields.
209
+ }
210
+ SchemaRef represents either a Schema or a $ref to a Schema. When serializing
211
+ and both fields are set, Ref is preferred over Value.
212
+
213
+ func (x *SchemaRef) CollectionName() string
214
+ CollectionName returns the JSON string used for a collection of these
215
+ components.
216
+
217
+ func (x *SchemaRef) JSONLookup(token string) (any, error)
218
+ JSONLookup implements
219
+ https://pkg.go.dev/github.com/go-openapi/jsonpointer#JSONPointable
220
+
221
+ func (x SchemaRef) MarshalJSON() ([]byte, error)
222
+ MarshalJSON returns the JSON encoding of SchemaRef.
223
+
224
+ func (x SchemaRef) MarshalYAML() (any, error)
225
+ MarshalYAML returns the YAML encoding of SchemaRef.
226
+
227
+ func (x *SchemaRef) RefPath() *url.URL
228
+ RefPath returns the path of the $ref relative to the root document.
229
+
230
+ func (x *SchemaRef) RefString() string
231
+ RefString returns the $ref value.
232
+
233
+ func (x *SchemaRef) UnmarshalJSON(data []byte) error
234
+ UnmarshalJSON sets SchemaRef to a copy of data.
235
+
236
+ type SchemaRefs []*SchemaRef
237
+
238
+ type Schemas map[string]*SchemaRef
239
+
133
240
type SecurityRequirements []map[string][]string
134
241
135
242
type SecurityScheme struct {
@@ -157,21 +264,21 @@ func (securityScheme *SecurityScheme) UnmarshalJSON(data []byte) error
157
264
type T struct {
158
265
Extensions map[string]any `json:"-" yaml:"-"`
159
266
160
- Swagger string `json:"swagger" yaml:"swagger"` // required
161
- Info openapi3.Info `json:"info" yaml:"info"` // required
162
- ExternalDocs *openapi3.ExternalDocs `json:"externalDocs,omitempty" yaml:"externalDocs,omitempty"`
163
- Schemes []string `json:"schemes,omitempty" yaml:"schemes,omitempty"`
164
- Consumes []string `json:"consumes,omitempty" yaml:"consumes,omitempty"`
165
- Produces []string `json:"produces,omitempty" yaml:"produces,omitempty"`
166
- Host string `json:"host,omitempty" yaml:"host,omitempty"`
167
- BasePath string `json:"basePath,omitempty" yaml:"basePath,omitempty"`
168
- Paths map[string]*PathItem `json:"paths,omitempty" yaml:"paths,omitempty"`
169
- Definitions map[string]*openapi3. SchemaRef `json:"definitions,omitempty" yaml:"definitions,omitempty"`
170
- Parameters map[string]*Parameter `json:"parameters,omitempty" yaml:"parameters,omitempty"`
171
- Responses map[string]*Response `json:"responses,omitempty" yaml:"responses,omitempty"`
172
- SecurityDefinitions map[string]*SecurityScheme `json:"securityDefinitions,omitempty" yaml:"securityDefinitions,omitempty"`
173
- Security SecurityRequirements `json:"security,omitempty" yaml:"security,omitempty"`
174
- Tags openapi3.Tags `json:"tags,omitempty" yaml:"tags,omitempty"`
267
+ Swagger string `json:"swagger" yaml:"swagger"` // required
268
+ Info openapi3.Info `json:"info" yaml:"info"` // required
269
+ ExternalDocs *openapi3.ExternalDocs `json:"externalDocs,omitempty" yaml:"externalDocs,omitempty"`
270
+ Schemes []string `json:"schemes,omitempty" yaml:"schemes,omitempty"`
271
+ Consumes []string `json:"consumes,omitempty" yaml:"consumes,omitempty"`
272
+ Produces []string `json:"produces,omitempty" yaml:"produces,omitempty"`
273
+ Host string `json:"host,omitempty" yaml:"host,omitempty"`
274
+ BasePath string `json:"basePath,omitempty" yaml:"basePath,omitempty"`
275
+ Paths map[string]*PathItem `json:"paths,omitempty" yaml:"paths,omitempty"`
276
+ Definitions map[string]*SchemaRef `json:"definitions,omitempty" yaml:"definitions,omitempty"`
277
+ Parameters map[string]*Parameter `json:"parameters,omitempty" yaml:"parameters,omitempty"`
278
+ Responses map[string]*Response `json:"responses,omitempty" yaml:"responses,omitempty"`
279
+ SecurityDefinitions map[string]*SecurityScheme `json:"securityDefinitions,omitempty" yaml:"securityDefinitions,omitempty"`
280
+ Security SecurityRequirements `json:"security,omitempty" yaml:"security,omitempty"`
281
+ Tags openapi3.Tags `json:"tags,omitempty" yaml:"tags,omitempty"`
175
282
}
176
283
T is the root of an OpenAPI v2 document
177
284
0 commit comments