forked from ogen-go/ogen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
spec.go
657 lines (582 loc) · 28.8 KB
/
spec.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
package ogen
import (
"encoding/json"
"github.com/go-faster/yaml"
"github.com/ogen-go/ogen/jsonschema"
"github.com/ogen-go/ogen/location"
)
type (
// Num represents JSON number.
Num = jsonschema.Num
// Enum is JSON Schema enum validator description.
Enum = jsonschema.Enum
// Default is a default value.
Default = jsonschema.Default
// ExampleValue is an example value.
ExampleValue = jsonschema.Example
// RawValue is a raw JSON value.
RawValue = jsonschema.RawValue
// Extensions is a map of OpenAPI extensions.
//
// See https://spec.openapis.org/oas/v3.1.0#specification-extensions.
Extensions = jsonschema.Extensions
// OpenAPICommon is a common OpenAPI object fields (extensions and locator).
OpenAPICommon = jsonschema.OpenAPICommon
// Locator stores location of JSON value.
Locator = location.Locator
)
// Spec is the root document object of the OpenAPI document.
//
// See https://spec.openapis.org/oas/v3.1.0#openapi-object.
type Spec struct {
// REQUIRED. This string MUST be the version number of the OpenAPI Specification
// that the OpenAPI document uses.
OpenAPI string `json:"openapi" yaml:"openapi"`
// Added just to detect v2 openAPI specifications and to pretty print version error.
Swagger string `json:"swagger,omitempty" yaml:"swagger,omitempty"`
// REQUIRED. Provides metadata about the API.
//
// The metadata MAY be used by tooling as required.
Info Info `json:"info" yaml:"info"`
// The default value for the `$schema` keyword within Schema Objects contained within this OAS document.
JSONSchemaDialect string `json:"jsonSchemaDialect,omitempty" yaml:"jsonSchemaDialect,omitempty"`
// An array of Server Objects, which provide connectivity information to a target server.
Servers []Server `json:"servers,omitempty" yaml:"servers,omitempty"`
// The available paths and operations for the API.
Paths Paths `json:"paths,omitempty" yaml:"paths,omitempty"`
// The incoming webhooks that MAY be received as part of this API and that
// the API consumer MAY choose to implement.
//
// Closely related to the `callbacks` feature, this section describes requests initiated other
// than by an API call, for example by an out of band registration.
//
// The key name is a unique string to refer to each webhook, while the (optionally referenced)
// PathItem Object describes a request that may be initiated by the API provider and the expected responses.
Webhooks map[string]*PathItem `json:"webhooks,omitempty" yaml:"webhooks,omitempty"`
// An element to hold various schemas for the document.
Components *Components `json:"components,omitempty" yaml:"components,omitempty"`
// A declaration of which security mechanisms can be used across the API.
// The list of values includes alternative security requirement objects that can be used.
//
// Only one of the security requirement objects need to be satisfied to authorize a request.
//
// Individual operations can override this definition.
Security SecurityRequirements `json:"security,omitempty" yaml:"security,omitempty"`
// A list of tags used by the specification with additional metadata.
// The order of the tags can be used to reflect on their order by the parsing
// tools. Not all tags that are used by the Operation Object must be declared.
// The tags that are not declared MAY be organized randomly or based on the tools' logic.
// Each tag name in the list MUST be unique.
Tags []Tag `json:"tags,omitempty" yaml:"tags,omitempty"`
// Additional external documentation.
ExternalDocs *ExternalDocumentation `json:"externalDocs,omitempty" yaml:"externalDocs,omitempty"`
// Specification extensions.
Extensions Extensions `json:"-" yaml:",inline"`
// Raw YAML node. Used by '$ref' resolvers.
Raw *yaml.Node `json:"-" yaml:"-"`
}
// UnmarshalYAML implements yaml.Unmarshaler.
func (s *Spec) UnmarshalYAML(n *yaml.Node) error {
type Alias Spec
var a Alias
if err := n.Decode(&a); err != nil {
return err
}
*s = Spec(a)
s.Raw = n
return nil
}
// UnmarshalJSON implements json.Unmarshaler.
func (s *Spec) UnmarshalJSON(bytes []byte) error {
type Alias Spec
var a Alias
if err := json.Unmarshal(bytes, &a); err != nil {
return err
}
*s = Spec(a)
var n yaml.Node
if err := yaml.Unmarshal(bytes, &n); err != nil {
return err
}
s.Raw = &n
return nil
}
// Init components of schema.
func (s *Spec) Init() {
if s.Components == nil {
s.Components = &Components{}
}
s.Components.Init()
}
// Info provides metadata about the API.
//
// The metadata MAY be used by the clients if needed,
// and MAY be presented in editing or documentation generation tools for convenience.
//
// See https://spec.openapis.org/oas/v3.1.0#info-object.
type Info struct {
// REQUIRED. The title of the API.
Title string `json:"title" yaml:"title"`
// A short summary of the API.
Summary string `json:"summary,omitempty" yaml:"summary,omitempty"`
// A short description of the API.
// CommonMark syntax MAY be used for rich text representation.
Description string `json:"description,omitempty" yaml:"description,omitempty"`
// A URL to the Terms of Service for the API. MUST be in the format of a URL.
TermsOfService string `json:"termsOfService,omitempty" yaml:"termsOfService,omitempty"`
// The contact information for the exposed API.
Contact *Contact `json:"contact,omitempty" yaml:"contact,omitempty"`
// The license information for the exposed API.
License *License `json:"license,omitempty" yaml:"license,omitempty"`
// REQUIRED. The version of the OpenAPI document.
Version string `json:"version" yaml:"version"`
// Specification extensions.
Extensions Extensions `json:"-" yaml:",inline"`
}
// Contact information for the exposed API.
//
// See https://spec.openapis.org/oas/v3.1.0#contact-object.
type Contact struct {
// The identifying name of the contact person/organization.
Name string `json:"name,omitempty" yaml:"name,omitempty"`
// The URL pointing to the contact information.
URL string `json:"url,omitempty" yaml:"url,omitempty"`
// The email address of the contact person/organization.
Email string `json:"email,omitempty" yaml:"email,omitempty"`
// Specification extensions.
Extensions Extensions `json:"-" yaml:",inline"`
}
// License information for the exposed API.
//
// See https://spec.openapis.org/oas/v3.1.0#license-object.
type License struct {
// REQUIRED. The license name used for the API.
Name string `json:"name" yaml:"name"`
// An SPDX license expression for the API.
Identifier string `json:"identifier,omitempty" yaml:"identifier,omitempty"`
// A URL to the license used for the API.
URL string `json:"url,omitempty" yaml:"url,omitempty"`
// Specification extensions.
Extensions Extensions `json:"-" yaml:",inline"`
}
// Server represents a Server.
//
// See https://spec.openapis.org/oas/v3.1.0#server-object.
type Server struct {
// REQUIRED. A URL to the target host. This URL supports Server Variables and MAY be relative,
// to indicate that the host location is relative to the location where the OpenAPI document is being served.
// Variable substitutions will be made when a variable is named in {brackets}.
URL string `json:"url" yaml:"url"`
// An optional string describing the host designated by the URL.
// CommonMark syntax MAY be used for rich text representation.
Description string `json:"description,omitempty" yaml:"description,omitempty"`
// A map between a variable name and its value. The value is used for substitution in the server's URL template.
Variables map[string]ServerVariable `json:"variables,omitempty" yaml:"variables,omitempty"`
Common OpenAPICommon `json:"-" yaml:",inline"`
}
// ServerVariable describes an object representing a Server Variable for server URL template substitution.
//
// See https://spec.openapis.org/oas/v3.1.0#server-variable-object
type ServerVariable struct {
// An enumeration of string values to be used if the substitution options are from a limited set.
//
// The array MUST NOT be empty.
Enum []string `json:"enum,omitempty" yaml:"enum,omitempty"`
// REQUIRED. The default value to use for substitution, which SHALL be sent if an alternate value is not supplied.
// Note this behavior is different than the Schema Object's treatment of default values, because in those
// cases parameter values are optional. If the enum is defined, the value MUST exist in the enum's values.
Default string `json:"default" yaml:"default"`
// An optional description for the server variable. CommonMark syntax MAY be used for rich text representation.
Description string `json:"description,omitempty" yaml:"description,omitempty"`
Common OpenAPICommon `json:"-" yaml:",inline"`
}
// Components Holds a set of reusable objects for different aspects of the OAS.
// All objects defined within the components object will have no effect on the API unless
// they are explicitly referenced from properties outside the components object.
//
// See https://spec.openapis.org/oas/v3.1.0#components-object.
type Components struct {
// An object to hold reusable Schema Objects.
Schemas map[string]*Schema `json:"schemas,omitempty" yaml:"schemas,omitempty"`
// An object to hold reusable Response Objects.
Responses map[string]*Response `json:"responses,omitempty" yaml:"responses,omitempty"`
// An object to hold reusable Parameter Objects.
Parameters map[string]*Parameter `json:"parameters,omitempty" yaml:"parameters,omitempty"`
// An object to hold reusable Example Objects.
Examples map[string]*Example `json:"examples,omitempty" yaml:"examples,omitempty"`
// An object to hold reusable Request Body Objects.
RequestBodies map[string]*RequestBody `json:"requestBodies,omitempty" yaml:"requestBodies,omitempty"`
// An object to hold reusable Header Objects.
Headers map[string]*Header `json:"headers,omitempty" yaml:"headers,omitempty"`
// An object to hold reusable Security Scheme Objects.
SecuritySchemes map[string]*SecurityScheme `json:"securitySchemes,omitempty" yaml:"securitySchemes,omitempty"`
// An object to hold reusable Link Objects.
Links map[string]*Link `json:"links,omitempty" yaml:"links,omitempty"`
// An object to hold reusable Callback Objects.
Callbacks map[string]*Callback `json:"callbacks,omitempty" yaml:"callbacks,omitempty"`
// An object to hold reusable Path Item Objects.
PathItems map[string]*PathItem `json:"pathItems,omitempty" yaml:"pathItems,omitempty"`
Common OpenAPICommon `json:"-" yaml:",inline"`
}
func initMapIfNil[K comparable, V any](m map[K]V) map[K]V {
if m == nil {
m = make(map[K]V)
}
return m
}
// Init initializes all fields.
func (c *Components) Init() {
if c == nil {
return
}
c.Schemas = initMapIfNil(c.Schemas)
c.Responses = initMapIfNil(c.Responses)
c.Parameters = initMapIfNil(c.Parameters)
c.Examples = initMapIfNil(c.Examples)
c.RequestBodies = initMapIfNil(c.RequestBodies)
c.Headers = initMapIfNil(c.Headers)
c.SecuritySchemes = initMapIfNil(c.SecuritySchemes)
c.Links = initMapIfNil(c.Links)
c.Callbacks = initMapIfNil(c.Callbacks)
c.PathItems = initMapIfNil(c.PathItems)
}
// Paths holds the relative paths to the individual endpoints and their operations.
// The path is appended to the URL from the Server Object in order to construct the full URL.
// The Paths MAY be empty, due to ACL constraints.
//
// See https://spec.openapis.org/oas/v3.1.0#paths-object.
type Paths map[string]*PathItem
// PathItem Describes the operations available on a single path.
// A Path Item MAY be empty, due to ACL constraints. The path itself is still exposed to the
// documentation viewer, but they will not know which operations and parameters are available.
//
// See https://spec.openapis.org/oas/v3.1.0#path-item-object.
type PathItem struct {
// Allows for an external definition of this path item.
// The referenced structure MUST be in the format of a Path Item Object.
// In case a Path Item Object field appears both
// in the defined object and the referenced object, the behavior is undefined.
Ref string `json:"$ref,omitempty" yaml:"$ref,omitempty"`
// An optional, string summary, intended to apply to all operations in this path.
Summary string `json:"summary,omitempty" yaml:"summary,omitempty"`
// An optional, string description, intended to apply to all operations in this path.
// CommonMark syntax MAY be used for rich text representation.
Description string `json:"description,omitempty" yaml:"description,omitempty"`
// A definition of a GET operation on this path.
Get *Operation `json:"get,omitempty" yaml:"get,omitempty"`
// A definition of a PUT operation on this path.
Put *Operation `json:"put,omitempty" yaml:"put,omitempty"`
// A definition of a POST operation on this path.
Post *Operation `json:"post,omitempty" yaml:"post,omitempty"`
// A definition of a DELETE operation on this path.
Delete *Operation `json:"delete,omitempty" yaml:"delete,omitempty"`
// A definition of a OPTIONS operation on this path.
Options *Operation `json:"options,omitempty" yaml:"options,omitempty"`
// A definition of a HEAD operation on this path.
Head *Operation `json:"head,omitempty" yaml:"head,omitempty"`
// A definition of a PATCH operation on this path.
Patch *Operation `json:"patch,omitempty" yaml:"patch,omitempty"`
// A definition of a TRACE operation on this path.
Trace *Operation `json:"trace,omitempty" yaml:"trace,omitempty"`
// An alternative server array to service all operations in this path.
Servers []Server `json:"servers,omitempty" yaml:"servers,omitempty"`
// A list of parameters that are applicable for all the operations described under this path.
//
// These parameters can be overridden at the operation level, but cannot be removed there.
//
// The list MUST NOT include duplicated parameters. A unique parameter is defined by
// a combination of a name and location.
Parameters []*Parameter `json:"parameters,omitempty" yaml:"parameters,omitempty"`
Common OpenAPICommon `json:"-" yaml:",inline"`
}
// Operation describes a single API operation on a path.
//
// See https://spec.openapis.org/oas/v3.1.0#operation-object.
type Operation struct {
// A list of tags for API documentation control.
// Tags can be used for logical grouping of operations by resources or any other qualifier.
Tags []string `json:"tags,omitempty" yaml:"tags,omitempty"`
// A short summary of what the operation does.
Summary string `json:"summary,omitempty" yaml:"summary,omitempty"`
// A verbose explanation of the operation behavior.
// CommonMark syntax MAY be used for rich text representation.
Description string `json:"description,omitempty" yaml:"description,omitempty"`
// Additional external documentation for this operation.
ExternalDocs *ExternalDocumentation `json:"externalDocs,omitempty" yaml:"externalDocs,omitempty"`
// Unique string used to identify the operation.
//
// The id MUST be unique among all operations described in the API.
//
// The operationId value is case-sensitive.
OperationID string `json:"operationId,omitempty" yaml:"operationId,omitempty"`
// A list of parameters that are applicable for this operation.
//
// If a parameter is already defined at the Path Item, the new definition will override it but
// can never remove it.
//
// The list MUST NOT include duplicated parameters. A unique parameter is defined by
// a combination of a name and location.
Parameters []*Parameter `json:"parameters,omitempty" yaml:"parameters,omitempty"`
// The request body applicable for this operation.
RequestBody *RequestBody `json:"requestBody,omitempty" yaml:"requestBody,omitempty"`
// The list of possible responses as they are returned from executing this operation.
Responses Responses `json:"responses,omitempty" yaml:"responses,omitempty"`
// A map of possible out-of band callbacks related to the parent operation.
//
// The key is a unique identifier for the Callback Object.
Callbacks map[string]*Callback `json:"callbacks,omitempty" yaml:"callbacks,omitempty"`
// Declares this operation to be deprecated
Deprecated bool `json:"deprecated,omitempty" yaml:"deprecated,omitempty"`
// A declaration of which security mechanisms can be used for this operation.
//
// The list of values includes alternative security requirement objects that can be used.
//
// Only one of the security requirement objects need to be satisfied to authorize a request.
Security SecurityRequirements `json:"security,omitempty" yaml:"security,omitempty"`
// An alternative server array to service this operation.
//
// If an alternative server object is specified at the Path Item Object or Root level,
// it will be overridden by this value.
Servers []Server `json:"servers,omitempty" yaml:"servers,omitempty"`
Common OpenAPICommon `json:"-" yaml:",inline"`
}
// ExternalDocumentation describes a reference to external resource for extended documentation.
//
// See https://spec.openapis.org/oas/v3.1.0#external-documentation-object.
type ExternalDocumentation struct {
// A description of the target documentation. CommonMark syntax MAY be used for rich text representation.
Description string `json:"description,omitempty" yaml:"description,omitempty"`
// REQUIRED. The URL for the target documentation. This MUST be in the form of a URL.
URL string `json:"url" yaml:"url"`
// Specification extensions.
Extensions Extensions `json:"-" yaml:",inline"`
}
// Parameter describes a single operation parameter.
// A unique parameter is defined by a combination of a name and location.
//
// See https://spec.openapis.org/oas/v3.1.0#parameter-object.
type Parameter struct {
Ref string `json:"$ref,omitempty" yaml:"$ref,omitempty"` // ref object
// REQUIRED. The name of the parameter. Parameter names are case sensitive.
Name string `json:"name,omitempty" yaml:"name,omitempty"`
// REQUIRED. The location of the parameter. Possible values are "query", "header", "path" or "cookie".
In string `json:"in,omitempty" yaml:"in,omitempty"`
// A brief description of the parameter. This could contain examples of use.
// CommonMark syntax MAY be used for rich text representation.
Description string `json:"description,omitempty" yaml:"description,omitempty"`
// Determines whether this parameter is mandatory.
// If the parameter location is "path", this property is REQUIRED
// and its value MUST be true.
// Otherwise, the property MAY be included and its default value is false.
Required bool `json:"required,omitempty" yaml:"required,omitempty"`
// Specifies that a parameter is deprecated and SHOULD be transitioned out of usage.
// Default value is false.
Deprecated bool `json:"deprecated,omitempty" yaml:"deprecated,omitempty"`
// Describes how the parameter value will be serialized
// depending on the type of the parameter value.
Style string `json:"style,omitempty" yaml:"style,omitempty"`
// When this is true, parameter values of type array or object
// generate separate parameters for each value of the array
// or key-value pair of the map.
// For other types of parameters this property has no effect.
Explode *bool `json:"explode,omitempty" yaml:"explode,omitempty"`
// Determines whether the parameter value SHOULD allow reserved characters, as defined by RFC 3986.
//
// This property only applies to parameters with an in value of query.
//
// The default value is false.
AllowReserved bool `json:"allowReserved,omitempty" yaml:"allowReserved,omitempty"`
// The schema defining the type used for the parameter.
Schema *Schema `json:"schema,omitempty" yaml:"schema,omitempty"`
// Example of the parameter's potential value.
Example ExampleValue `json:"example,omitempty" yaml:"example,omitempty"`
// Examples of the parameter's potential value.
Examples map[string]*Example `json:"examples,omitempty" yaml:"examples,omitempty"`
// For more complex scenarios, the content property can define the media type and schema of the parameter.
// A parameter MUST contain either a schema property, or a content property, but not both.
// When example or examples are provided in conjunction with the schema object,
// the example MUST follow the prescribed serialization strategy for the parameter.
//
// A map containing the representations for the parameter.
// The key is the media type and the value describes it.
// The map MUST only contain one entry.
Content map[string]Media `json:"content,omitempty" yaml:"content,omitempty"`
Common OpenAPICommon `json:"-" yaml:",inline"`
}
// RequestBody describes a single request body.
//
// See https://spec.openapis.org/oas/v3.1.0#request-body-object.
type RequestBody struct {
Ref string `json:"$ref,omitempty" yaml:"$ref,omitempty"` // ref object
// A brief description of the request body. This could contain examples of use.
// CommonMark syntax MAY be used for rich text representation.
Description string `json:"description,omitempty" yaml:"description,omitempty"`
// REQUIRED. The content of the request body.
//
// The key is a media type or media type range and the value describes it.
//
// For requests that match multiple keys, only the most specific key is applicable.
// e.g. text/plain overrides text/*
Content map[string]Media `json:"content,omitempty" yaml:"content,omitempty"`
// Determines if the request body is required in the request. Defaults to false.
Required bool `json:"required,omitempty" yaml:"required,omitempty"`
Common OpenAPICommon `json:"-" yaml:",inline"`
}
// Media provides schema and examples for the media type identified by its key.
//
// See https://spec.openapis.org/oas/v3.1.0#media-type-object.
type Media struct {
// The schema defining the content of the request, response, or parameter.
Schema *Schema `json:"schema,omitempty" yaml:"schema,omitempty"`
// Example of the media type.
Example ExampleValue `json:"example,omitempty" yaml:"example,omitempty"`
// Examples of the media type.
Examples map[string]*Example `json:"examples,omitempty" yaml:"examples,omitempty"`
// A map between a property name and its encoding information.
//
// The key, being the property name, MUST exist in the schema as a property.
//
// The encoding object SHALL only apply to requestBody objects when the media
// type is multipart or application/x-www-form-urlencoded.
Encoding map[string]Encoding `json:"encoding,omitempty" yaml:"encoding,omitempty"`
Common OpenAPICommon `json:"-" yaml:",inline"`
}
// Encoding describes single encoding definition applied to a single schema property.
//
// See https://spec.openapis.org/oas/v3.1.0#encoding-object.
type Encoding struct {
// The Content-Type for encoding a specific property.
ContentType string `json:"contentType,omitempty" yaml:"contentType,omitempty"`
// A map allowing additional information to be provided as headers, for example Content-Disposition.
// Content-Type is described separately and SHALL be ignored in this section. This property SHALL be
// ignored if the request body media type is not a multipart.
Headers map[string]*Header `json:"headers,omitempty" yaml:"headers,omitempty"`
// Describes how the parameter value will be serialized
// depending on the type of the parameter value.
Style string `json:"style,omitempty" yaml:"style,omitempty"`
// When this is true, parameter values of type array or object
// generate separate parameters for each value of the array
// or key-value pair of the map.
// For other types of parameters this property has no effect.
Explode *bool `json:"explode,omitempty" yaml:"explode,omitempty"`
// Determines whether the parameter value SHOULD allow reserved characters, as defined by
// RFC3986 :/?#[]@!$&'()*+,;= to be included without percent-encoding.
// The default value is false. This property SHALL be ignored if the request body media type
// is not application/x-www-form-urlencoded.
AllowReserved bool `json:"allowReserved,omitempty" yaml:"allowReserved,omitempty"`
Common OpenAPICommon `json:"-" yaml:",inline"`
}
// Responses is a container for the expected responses of an operation.
//
// The container maps the HTTP response code to the expected response.
//
// The `default` MAY be used as a default response object for all HTTP
// codes that are not covered individually by the Responses Object.
//
// The Responses Object MUST contain at least one response code, and if only one
// response code is provided it SHOULD be the response for a successful operation call.
//
// See https://spec.openapis.org/oas/v3.1.0#responses-object.
type Responses map[string]*Response
// Response describes a single response from an API Operation,
// including design-time, static links to operations based on the response.
//
// See https://spec.openapis.org/oas/v3.1.0#response-object.
type Response struct {
Ref string `json:"$ref,omitempty" yaml:"$ref,omitempty"` // ref object
// REQUIRED. A description of the response.
// CommonMark syntax MAY be used for rich text representation.
Description string `json:"description,omitempty" yaml:"description,omitempty"`
// Maps a header name to its definition.
//
// RFC7230 states header names are case insensitive.
//
// If a response header is defined with the name "Content-Type", it SHALL be ignored.
Headers map[string]*Header `json:"headers,omitempty" yaml:"headers,omitempty"`
// A map containing descriptions of potential response payloads.
//
// The key is a media type or media type range and the value describes it.
//
// For requests that match multiple keys, only the most specific key is applicable.
// e.g. text/plain overrides text/*
Content map[string]Media `json:"content,omitempty" yaml:"content,omitempty"`
// A map of operations links that can be followed from the response.
//
// The key of the map is a short name for the link, following the naming constraints
// of the names for Component Objects.
Links map[string]*Link `json:"links,omitempty" yaml:"links,omitempty"`
Common OpenAPICommon `json:"-" yaml:",inline"`
}
// Callback is a map of possible out-of band callbacks related to the parent operation.
//
// Each value in the map is a Path Item Object that describes a set of requests that may be
// initiated by the API provider and the expected responses.
//
// The key value used to identify the path item object is an expression, evaluated at runtime,
// that identifies a URL to use for the callback operation.
//
// To describe incoming requests from the API provider independent from another
// API call, use the `webhooks` field.
//
// See https://spec.openapis.org/oas/v3.1.0#callback-object.
type Callback map[string]*PathItem
// Example object.
//
// See https://spec.openapis.org/oas/v3.1.0#example-object.
type Example struct {
Ref string `json:"$ref,omitempty" yaml:"$ref,omitempty"` // ref object
// Short description for the example.
Summary string `json:"summary,omitempty" yaml:"summary,omitempty"`
// Long description for the example.
// CommonMark syntax MAY be used for rich text representation.
Description string `json:"description,omitempty" yaml:"description,omitempty"`
// Embedded literal example.
Value ExampleValue `json:"value,omitempty" yaml:"value,omitempty"`
// A URI that points to the literal example.
ExternalValue string `json:"externalValue,omitempty" yaml:"externalValue,omitempty"`
Common OpenAPICommon `json:"-" yaml:",inline"`
}
// Link describes a possible design-time link for a response.
//
// See https://spec.openapis.org/oas/v3.1.0#link-object.
type Link struct {
Ref string `json:"$ref,omitempty" yaml:"$ref,omitempty"` // ref object
// A relative or absolute URI reference to an OAS operation.
//
// This field is mutually exclusive of the operationId field, and MUST point to an Operation Object.
OperationRef string `json:"operationRef,omitempty" yaml:"operationRef,omitempty"`
// The name of an existing, resolvable OAS operation, as defined with a unique operationId.
//
// This field is mutually exclusive of the operationRef field.
OperationID string `json:"operationId,omitempty" yaml:"operationId,omitempty"`
// A map representing parameters to pass to an operation as specified with operationId or identified
// via operationRef.
//
// The key is the parameter name to be used, whereas the value can be a constant or an expression to be
// evaluated and passed to the linked operation.
Parameters map[string]RawValue `json:"parameters,omitempty" yaml:"parameters,omitempty"`
Common OpenAPICommon `json:"-" yaml:",inline"`
}
// Header describes header response.
//
// Header Object follows the structure of the Parameter Object with the following changes:
//
// 1. `name` MUST NOT be specified, it is given in the corresponding headers map.
// 2. `in` MUST NOT be specified, it is implicitly in header.
// 3. All traits that are affected by the location MUST be applicable to a location of header.
//
// See https://spec.openapis.org/oas/v3.1.0#header-object.
type Header = Parameter
// Tag adds metadata to a single tag that is used by the Operation Object.
//
// See https://spec.openapis.org/oas/v3.1.0#tag-object
type Tag struct {
// REQUIRED. The name of the tag.
Name string `json:"name" yaml:"name"`
// A description for the tag. CommonMark syntax MAY be used for rich text representation.
Description string `json:"description,omitempty" yaml:"description,omitempty"`
// Additional external documentation for this tag.
ExternalDocs *ExternalDocumentation `json:"externalDocs,omitempty" yaml:"externalDocs,omitempty"`
// Specification extensions.
Extensions Extensions `json:"-" yaml:",inline"`
}