Skip to content

Commit c9409aa

Browse files
committed
feat: add description and documentation links for oas 3.2
1 parent b37cfd7 commit c9409aa

1 file changed

Lines changed: 121 additions & 23 deletions

File tree

packages/core/src/types/oas3_2.ts

Lines changed: 121 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,65 @@ const Root: NodeType = {
66
...Oas3_1Types.Root,
77
properties: {
88
...Oas3_1Types.Root.properties,
9-
$self: { type: 'string' },
9+
$self: {
10+
type: 'string',
11+
description:
12+
'This string MUST be in the form of a URI reference as defined by [RFC3986] Section 4.1. The $self field provides the self-assigned URI of this document, which also serves as its base URI in accordance with [RFC3986] Section 5.1.1. Implementations MUST support identifying the targets of API description URIs using the URI defined by this field when it is present. See Establishing the Base URI for the base URI behavior when $self is absent or relative, and see Appendix F for examples of using $self to resolve references.',
13+
},
1014
},
15+
documentationLink: 'https://spec.openapis.org/oas/v3.2.0.html#security-scheme-object',
1116
};
1217

1318
const Tag: NodeType = {
1419
...Oas3_1Types.Tag,
1520
properties: {
1621
...Oas3_1Types.Tag.properties,
17-
kind: { type: 'string' },
18-
parent: { type: 'string' },
19-
summary: { type: 'string' },
22+
kind: {
23+
type: 'string',
24+
description:
25+
'A machine-readable string to categorize what sort of tag it is. Any string value can be used; common uses are nav for Navigation, badge for visible badges, audience for APIs used by different groups. A registry of the most commonly used values is available.',
26+
},
27+
parent: {
28+
type: 'string',
29+
description:
30+
'The name of a tag that this tag is nested under. The named tag MUST exist in the API description, and circular references between parent and child tags MUST NOT be used.',
31+
},
32+
summary: {
33+
type: 'string',
34+
description: 'A short summary of the tag, used for display purposes.',
35+
},
2036
},
37+
documentationLink: 'https://spec.openapis.org/oas/v3.2.0.html#tag-object',
38+
description:
39+
'Adds metadata to a single tag that is used by the Operation Object. It is not mandatory to have a Tag Object per tag defined in the Operation Object instances.',
2140
};
2241

2342
const Server: NodeType = {
2443
...Oas3_1Types.Server,
2544
properties: {
2645
...Oas3_1Types.Server.properties,
27-
name: { type: 'string' },
46+
name: {
47+
type: 'string',
48+
description: 'An optional unique string to refer to the host designated by the URL.',
49+
},
2850
},
51+
documentationLink: 'https://spec.openapis.org/oas/v3.2.0.html#server-object',
52+
description: 'An object representing a Server.',
2953
};
3054

3155
const SecurityScheme: NodeType = {
3256
...Oas3_1Types.SecurityScheme,
3357
properties: {
3458
...Oas3_1Types.SecurityScheme.properties,
35-
deprecated: { type: 'boolean' }, // added in OAS 3.2
36-
oauth2MetadataUrl: { type: 'string' }, // added in OAS 3.2
59+
deprecated: {
60+
type: 'boolean',
61+
description:
62+
'Declares this security scheme to be deprecated. Consumers SHOULD refrain from usage of the declared scheme. Default value is false.',
63+
}, // added in OAS 3.2
64+
oauth2MetadataUrl: {
65+
type: 'string',
66+
description: 'URL to the OAuth2 authorization server metadata [RFC8414]. TLS is required.',
67+
}, // added in OAS 3.2
3768
},
3869
allowed(value) {
3970
switch (value?.type) {
@@ -126,6 +157,8 @@ const SecurityScheme: NodeType = {
126157
];
127158
}
128159
},
160+
documentationLink: 'https://spec.openapis.org/oas/v3.2.0.html#security-scheme-object',
161+
description: 'Defines a security scheme that can be used by the operations.',
129162
};
130163

131164
const OAuth2Flows: NodeType = {
@@ -138,13 +171,29 @@ const OAuth2Flows: NodeType = {
138171

139172
const DeviceAuthorization: NodeType = {
140173
properties: {
141-
deviceAuthorizationUrl: { type: 'string' },
142-
tokenUrl: { type: 'string' },
143-
refreshUrl: { type: 'string' },
144-
scopes: mapOf('string'),
174+
deviceAuthorizationUrl: {
175+
type: 'string',
176+
description:
177+
'REQUIRED. The device authorization URL to be used for this flow. This MUST be in the form of a URL. The OAuth2 standard requires the use of TLS.',
178+
},
179+
tokenUrl: {
180+
type: 'string',
181+
description:
182+
'REQUIRED. The token URL to be used for this flow. This MUST be in the form of a URL. The OAuth2 standard requires the use of TLS.',
183+
},
184+
refreshUrl: {
185+
type: 'string',
186+
description:
187+
'The URL to be used for obtaining refresh tokens. This MUST be in the form of a URL. The OAuth2 standard requires the use of TLS.',
188+
},
189+
scopes: mapOf('string', {
190+
description:
191+
'REQUIRED. The available scopes for the OAuth2 security scheme. A map between the scope name and a short description for it. The map MAY be empty.',
192+
}),
145193
},
146194
required: ['deviceAuthorizationUrl', 'tokenUrl', 'scopes'],
147195
extensionsPrefix: 'x-',
196+
description: 'Configuration for the OAuth Device Authorization flow.',
148197
};
149198

150199
const PathItem: NodeType = {
@@ -160,15 +209,22 @@ const Parameter: NodeType = {
160209
...Oas3_1Types.Parameter,
161210
properties: {
162211
...Oas3_1Types.Parameter.properties,
163-
in: { enum: ['query', 'header', 'path', 'cookie', 'querystring'] },
212+
in: {
213+
description:
214+
'REQUIRED. The location of the parameter. Possible values are "query", "querystring", "header", "path" or "cookie".',
215+
enum: ['query', 'header', 'path', 'cookie', 'querystring'],
216+
},
164217
},
165218
};
166219

167220
const Response: Omit<NodeType, 'required'> = {
168221
...Oas3_1Types.Response,
169222
properties: {
170223
...Oas3_1Types.Response.properties,
171-
summary: { type: 'string' },
224+
summary: {
225+
type: 'string',
226+
description: 'A short summary of the meaning of the response.',
227+
},
172228
},
173229
};
174230

@@ -177,7 +233,10 @@ const MediaType: NodeType = {
177233
properties: {
178234
...Oas3_1Types.MediaType.properties,
179235
itemSchema: 'Schema',
180-
prefixEncoding: listOf('Encoding'),
236+
prefixEncoding: listOf('Encoding', {
237+
description:
238+
'A map between a property name and its encoding information, as defined under Encoding By Name. The encoding field SHALL only apply when the media type is multipart or application/x-www-form-urlencoded. If no Encoding Object is provided for a property, the behavior is determined by the default values documented for the Encoding Object. This field MUST NOT be present if prefixEncoding or itemEncoding are present.',
239+
}),
181240
itemEncoding: 'Encoding',
182241
},
183242
};
@@ -186,29 +245,68 @@ const Discriminator: NodeType = {
186245
...Oas3_1Types.Discriminator,
187246
properties: {
188247
...Oas3_1Types.Discriminator.properties,
189-
defaultMapping: { type: 'string' },
248+
defaultMapping: {
249+
type: 'string',
250+
description:
251+
'The schema name or URI reference to a schema that is expected to validate the structure of the model when the discriminating property is not present in the payload or contains a value for which there is no explicit or implicit mapping.',
252+
},
190253
},
191254
};
192255

193256
const Example: NodeType = {
194257
...Oas3_1Types.Example,
195258
properties: {
196259
...Oas3_1Types.Example.properties,
197-
dataValue: { resolvable: false },
198-
serializedValue: { type: 'string' },
260+
dataValue: {
261+
resolvable: false,
262+
description:
263+
'An example of the data structure that MUST be valid according to the relevant Schema Object. If this field is present, value MUST be absent.',
264+
},
265+
serializedValue: {
266+
type: 'string',
267+
description:
268+
'An example of the serialized form of the value, including encoding and escaping as described under Validating Examples. If dataValue is present, then this field SHOULD contain the serialization of the given data. Otherwise, it SHOULD be the valid serialization of a data value that itself MUST be valid as described for dataValue. This field SHOULD NOT be used if the serialization format is JSON, as the data form is easier to work with. If this field is present, value, and externalValue MUST be absent.',
269+
},
199270
},
200271
};
201272

202273
const Xml: NodeType = {
203274
properties: {
204-
nodeType: { type: 'string', enum: ['element', 'attribute', 'text', 'cdata', 'none'] },
205-
name: { type: 'string' },
206-
namespace: { type: 'string' },
207-
prefix: { type: 'string' },
208-
attribute: { type: 'boolean' }, // Deprecated in OAS 3.2: Use nodeType: "attribute" instead
209-
wrapped: { type: 'boolean' }, // Deprecated in OAS 3.2: Use nodeType: "element" instead
275+
nodeType: {
276+
type: 'string',
277+
enum: ['element', 'attribute', 'text', 'cdata', 'none'],
278+
description:
279+
'One of element, attribute, text, cdata, or none, as explained under XML Node Types. The default value is none if $ref, $dynamicRef, or type: "array" is present in the Schema Object containing the XML Object, and element otherwise.',
280+
},
281+
name: {
282+
type: 'string',
283+
description:
284+
'Sets the name of the element/attribute corresponding to the schema, replacing the name that was inferred as described under XML Node Names. This field SHALL be ignored if the nodeType is text, cdata, or none.',
285+
},
286+
namespace: {
287+
type: 'string',
288+
description:
289+
'The IRI ([RFC3987]) of the namespace definition. Value MUST be in the form of a non-relative IRI.',
290+
},
291+
prefix: {
292+
type: 'string',
293+
description: 'The prefix to be used for the name.',
294+
},
295+
attribute: {
296+
type: 'boolean',
297+
description:
298+
'Declares whether the property definition translates to an attribute instead of an element. Default value is false. If nodeType is present, this field MUST NOT be present.Deprecated: Use nodeType: "attribute" instead of attribute: true.',
299+
},
300+
wrapped: {
301+
type: 'boolean',
302+
description:
303+
'MAY be used only for an array definition. Signifies whether the array is wrapped (for example, <books><book/><book/></books>) or unwrapped (<book/><book/>). Default value is false. The definition takes effect only when defined alongside type being "array" (outside the items). If nodeType is present, this field MUST NOT be present. Deprecated: Use nodeType: "element" instead of wrapped: true.',
304+
}, // Deprecated in OAS 3.2: Use nodeType: "element" instead
210305
},
211306
extensionsPrefix: 'x-',
307+
documentationLink: 'https://spec.openapis.org/oas/v3.2.0.html#xml-object',
308+
description:
309+
'A metadata object that allows for more fine-tuned XML model definitions. When using a Schema Object with XML, if no XML Object is present, the behavior is determined by the XML Object’s default field values.',
212310
};
213311

214312
// based on draft-2020-12

0 commit comments

Comments
 (0)