oas 18.2.2 → 18.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/@types/index.d.ts +42 -39
- package/@types/lib/dedupe-common-parameters.d.ts +2 -2
- package/@types/lib/find-schema-definition.d.ts +2 -1
- package/@types/lib/get-auth.d.ts +9 -6
- package/@types/lib/get-mediatype-examples.d.ts +3 -3
- package/@types/lib/openapi-to-json-schema.d.ts +28 -21
- package/@types/operation/get-callback-examples.d.ts +2 -1
- package/@types/operation/get-parameters-as-json-schema.d.ts +2 -1
- package/@types/operation.d.ts +15 -13
- package/@types/samples/index.d.ts +3 -2
- package/CHANGELOG.md +6 -0
- package/dist/index.js +83 -67
- package/dist/lib/clone-object.js +3 -0
- package/dist/lib/dedupe-common-parameters.js +2 -2
- package/dist/lib/find-schema-definition.js +2 -1
- package/dist/lib/get-auth.js +9 -6
- package/dist/lib/get-mediatype-examples.js +5 -5
- package/dist/lib/openapi-to-json-schema.js +139 -87
- package/dist/operation/get-callback-examples.js +2 -1
- package/dist/operation/get-parameters-as-json-schema.js +43 -29
- package/dist/operation/get-requestbody-examples.js +2 -2
- package/dist/operation/get-response-as-json-schema.js +16 -13
- package/dist/operation/get-response-examples.js +2 -1
- package/dist/operation.js +23 -20
- package/dist/samples/index.js +7 -5
- package/package.json +10 -12
- package/src/cli/lib/utils.js +2 -1
- package/src/index.ts +88 -74
- package/src/lib/clone-object.ts +4 -0
- package/src/lib/dedupe-common-parameters.ts +2 -2
- package/src/lib/find-schema-definition.ts +2 -1
- package/src/lib/get-auth.ts +11 -7
- package/src/lib/get-mediatype-examples.ts +5 -5
- package/src/lib/openapi-to-json-schema.ts +145 -90
- package/src/operation/get-callback-examples.ts +2 -1
- package/src/operation/get-parameters-as-json-schema.ts +47 -29
- package/src/operation/get-requestbody-examples.ts +2 -2
- package/src/operation/get-response-as-json-schema.ts +16 -13
- package/src/operation/get-response-examples.ts +2 -1
- package/src/operation.ts +23 -20
- package/src/rmoas.types.ts +4 -3
- package/src/samples/index.ts +7 -5
package/@types/index.d.ts
CHANGED
|
@@ -29,19 +29,17 @@ export default class Oas {
|
|
|
29
29
|
*/
|
|
30
30
|
user: RMOAS.User;
|
|
31
31
|
/**
|
|
32
|
-
* Internal storage array that the library utilizes to keep track of the times the
|
|
33
|
-
* called so that if you initiate multiple promises they'll all
|
|
34
|
-
* dereference call completed.
|
|
35
|
-
*
|
|
36
|
-
* @todo These are always `Promise.resolve` and `Promise.reject`. Make these types more specific than `any`.
|
|
32
|
+
* Internal storage array that the library utilizes to keep track of the times the
|
|
33
|
+
* {@see Oas.dereference} has been called so that if you initiate multiple promises they'll all
|
|
34
|
+
* end up returning the same data set once the initial dereference call completed.
|
|
37
35
|
*/
|
|
38
36
|
protected promises: {
|
|
39
37
|
resolve: any;
|
|
40
38
|
reject: any;
|
|
41
39
|
}[];
|
|
42
40
|
/**
|
|
43
|
-
* Internal storage array that the library utilizes to keep track of its `dereferencing` state so
|
|
44
|
-
* multiple dereferencing processes.
|
|
41
|
+
* Internal storage array that the library utilizes to keep track of its `dereferencing` state so
|
|
42
|
+
* it doesn't initiate multiple dereferencing processes.
|
|
45
43
|
*/
|
|
46
44
|
protected dereferencing: {
|
|
47
45
|
processing: boolean;
|
|
@@ -49,16 +47,18 @@ export default class Oas {
|
|
|
49
47
|
};
|
|
50
48
|
/**
|
|
51
49
|
* @param oas An OpenAPI definition.
|
|
52
|
-
* @param user The information about a user that we should use when pulling auth tokens from
|
|
50
|
+
* @param user The information about a user that we should use when pulling auth tokens from
|
|
51
|
+
* security schemes.
|
|
53
52
|
*/
|
|
54
53
|
constructor(oas: RMOAS.OASDocument, user?: RMOAS.User);
|
|
55
54
|
/**
|
|
56
|
-
* This will initialize a new instance of the `Oas` class. This method is useful if you're using
|
|
57
|
-
* attempting to supply an untyped JSON object into `Oas` as it will force-type
|
|
58
|
-
* you.
|
|
55
|
+
* This will initialize a new instance of the `Oas` class. This method is useful if you're using
|
|
56
|
+
* Typescript and are attempting to supply an untyped JSON object into `Oas` as it will force-type
|
|
57
|
+
* that object to an `OASDocument` for you.
|
|
59
58
|
*
|
|
60
59
|
* @param oas An OpenAPI definition.
|
|
61
|
-
* @param user The information about a user that we should use when pulling auth tokens from
|
|
60
|
+
* @param user The information about a user that we should use when pulling auth tokens from
|
|
61
|
+
* security schemes.
|
|
62
62
|
*/
|
|
63
63
|
static init(oas: Record<string, unknown> | RMOAS.OASDocument, user?: RMOAS.User): Oas;
|
|
64
64
|
/**
|
|
@@ -89,11 +89,12 @@ export default class Oas {
|
|
|
89
89
|
enum: string[];
|
|
90
90
|
})[];
|
|
91
91
|
/**
|
|
92
|
-
* With a fully composed server URL, run through our list of known OAS servers and return back
|
|
93
|
-
* selected along with any contained server variables split out.
|
|
92
|
+
* With a fully composed server URL, run through our list of known OAS servers and return back
|
|
93
|
+
* which server URL was selected along with any contained server variables split out.
|
|
94
94
|
*
|
|
95
|
-
* For example, if you have an OAS server URL of `https://{name}.example.com:{port}/{basePath}`,
|
|
96
|
-
* `https://buster.example.com:3000/pet` to this function, you'll get back the
|
|
95
|
+
* For example, if you have an OAS server URL of `https://{name}.example.com:{port}/{basePath}`,
|
|
96
|
+
* and pass in `https://buster.example.com:3000/pet` to this function, you'll get back the
|
|
97
|
+
* following:
|
|
97
98
|
*
|
|
98
99
|
* { selected: 0, variables: { name: 'buster', port: 3000, basePath: 'pet' } }
|
|
99
100
|
*
|
|
@@ -110,15 +111,15 @@ export default class Oas {
|
|
|
110
111
|
*
|
|
111
112
|
* There are a couple ways that this will utilize variable data:
|
|
112
113
|
*
|
|
113
|
-
* - If data is stored in `this.user` and it matches up with the variable name in the URL user
|
|
114
|
-
* will always take priority. See `getUserVariable` for some more information on how this
|
|
115
|
-
* `this.user`.
|
|
114
|
+
* - If data is stored in `this.user` and it matches up with the variable name in the URL user
|
|
115
|
+
* data will always take priority. See `getUserVariable` for some more information on how this
|
|
116
|
+
* data is pulled from `this.user`.
|
|
116
117
|
* - Supplying a `variables` object. This incoming `variables` object can be two formats:
|
|
117
|
-
* `{ variableName: { default: 'value' } }` and `{ variableName: 'value' }`. If the former is
|
|
118
|
-
* take prescendence over the latter.
|
|
118
|
+
* `{ variableName: { default: 'value' } }` and `{ variableName: 'value' }`. If the former is
|
|
119
|
+
* present, that will take prescendence over the latter.
|
|
119
120
|
*
|
|
120
|
-
* If no variables supplied match up with the template name, the template name will instead be
|
|
121
|
-
* data.
|
|
121
|
+
* If no variables supplied match up with the template name, the template name will instead be
|
|
122
|
+
* used as the variable data.
|
|
122
123
|
*
|
|
123
124
|
* @param url A URL to swap variables into.
|
|
124
125
|
* @param variables An object containing variables to swap into the URL.
|
|
@@ -137,31 +138,33 @@ export default class Oas {
|
|
|
137
138
|
}): Operation;
|
|
138
139
|
findOperationMatches(url: string): PathMatches;
|
|
139
140
|
/**
|
|
140
|
-
* Discover an operation in an OAS from a fully-formed URL and HTTP method. Will return an object
|
|
141
|
-
* object and another one for `operation`. This differs from `getOperation()`
|
|
142
|
-
* of the `Operation` class.
|
|
141
|
+
* Discover an operation in an OAS from a fully-formed URL and HTTP method. Will return an object
|
|
142
|
+
* containing a `url` object and another one for `operation`. This differs from `getOperation()`
|
|
143
|
+
* in that it does not return an instance of the `Operation` class.
|
|
143
144
|
*
|
|
144
145
|
* @param url A full URL to look up.
|
|
145
146
|
* @param method The cooresponding HTTP method to look up.
|
|
146
147
|
*/
|
|
147
148
|
findOperation(url: string, method: RMOAS.HttpMethods): PathMatch;
|
|
148
149
|
/**
|
|
149
|
-
* Discover an operation in an OAS from a fully-formed URL without an HTTP method. Will return an
|
|
150
|
-
* `url` object and another one for `operation`.
|
|
150
|
+
* Discover an operation in an OAS from a fully-formed URL without an HTTP method. Will return an
|
|
151
|
+
* object containing a `url` object and another one for `operation`.
|
|
151
152
|
*
|
|
152
153
|
* @param url A full URL to look up.
|
|
153
154
|
*/
|
|
154
155
|
findOperationWithoutMethod(url: string): PathMatch;
|
|
155
156
|
/**
|
|
156
|
-
* Retrieve an operation in an OAS from a fully-formed URL and HTTP method. Differs from
|
|
157
|
-
* this method will return an `Operation` instance,
|
|
157
|
+
* Retrieve an operation in an OAS from a fully-formed URL and HTTP method. Differs from
|
|
158
|
+
* `findOperation` in that while this method will return an `Operation` instance,
|
|
159
|
+
* `findOperation()` does not.
|
|
158
160
|
*
|
|
159
161
|
* @param url A full URL to look up.
|
|
160
162
|
* @param method The cooresponding HTTP method to look up.
|
|
161
163
|
*/
|
|
162
164
|
getOperation(url: string, method: RMOAS.HttpMethods): Operation;
|
|
163
165
|
/**
|
|
164
|
-
* With an object of user information, retrieve the appropriate API auth keys from the current
|
|
166
|
+
* With an object of user information, retrieve the appropriate API auth keys from the current
|
|
167
|
+
* OAS definition.
|
|
165
168
|
*
|
|
166
169
|
* @see {@link https://docs.readme.com/docs/passing-data-to-jwt}
|
|
167
170
|
* @param user User
|
|
@@ -171,16 +174,16 @@ export default class Oas {
|
|
|
171
174
|
[x: string]: unknown;
|
|
172
175
|
};
|
|
173
176
|
/**
|
|
174
|
-
* Returns the `paths` object that exists in this API definition but with every `method` mapped
|
|
175
|
-
* the `Operation` class.
|
|
177
|
+
* Returns the `paths` object that exists in this API definition but with every `method` mapped
|
|
178
|
+
* to an instance of the `Operation` class.
|
|
176
179
|
*
|
|
177
180
|
* @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.0.md#oasObject}
|
|
178
181
|
* @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#openapi-object}
|
|
179
182
|
*/
|
|
180
183
|
getPaths(): Record<string, Record<RMOAS.HttpMethods, Operation | Webhook>>;
|
|
181
184
|
/**
|
|
182
|
-
* Returns the `webhooks` object that exists in this API definition but with every `method`
|
|
183
|
-
* the `Operation` class.
|
|
185
|
+
* Returns the `webhooks` object that exists in this API definition but with every `method`
|
|
186
|
+
* mapped to an instance of the `Operation` class.
|
|
184
187
|
*
|
|
185
188
|
* @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.0.md#oasObject}
|
|
186
189
|
* @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#openapi-object}
|
|
@@ -193,8 +196,8 @@ export default class Oas {
|
|
|
193
196
|
*
|
|
194
197
|
* @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.0.md#oasObject}
|
|
195
198
|
* @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#openapi-object}
|
|
196
|
-
* @param setIfMissing If a tag is not present on an operation that operations path will be added
|
|
197
|
-
* tags returned.
|
|
199
|
+
* @param setIfMissing If a tag is not present on an operation that operations path will be added
|
|
200
|
+
* into the list of tags returned.
|
|
198
201
|
*/
|
|
199
202
|
getTags(setIfMissing?: boolean): unknown[];
|
|
200
203
|
/**
|
|
@@ -214,8 +217,8 @@ export default class Oas {
|
|
|
214
217
|
*/
|
|
215
218
|
getExtension(extension: string): unknown;
|
|
216
219
|
/**
|
|
217
|
-
* Dereference the current OAS definition so it can be parsed free of worries of `$ref` schemas
|
|
218
|
-
* structures.
|
|
220
|
+
* Dereference the current OAS definition so it can be parsed free of worries of `$ref` schemas
|
|
221
|
+
* and circular structures.
|
|
219
222
|
*
|
|
220
223
|
* @param opts
|
|
221
224
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as RMOAS from '../rmoas.types';
|
|
2
2
|
/**
|
|
3
|
-
* With an array of common parameters filter down them to what isn't already present in a list of
|
|
4
|
-
* parameters.
|
|
3
|
+
* With an array of common parameters filter down them to what isn't already present in a list of
|
|
4
|
+
* non-common parameters.
|
|
5
5
|
*
|
|
6
6
|
* @param parameters
|
|
7
7
|
* @param commonParameters
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Lookup a reference pointer within an OpenAPI definition and return the schema that it resolves
|
|
2
|
+
* Lookup a reference pointer within an OpenAPI definition and return the schema that it resolves
|
|
3
|
+
* to.
|
|
3
4
|
*
|
|
4
5
|
* @deprecated
|
|
5
6
|
* @param $ref Reference to look up a schema for.
|
package/@types/lib/get-auth.d.ts
CHANGED
|
@@ -5,12 +5,14 @@ declare type authKey = null | unknown | {
|
|
|
5
5
|
password: string | number;
|
|
6
6
|
};
|
|
7
7
|
/**
|
|
8
|
-
* Retrieve auth keys for a specific security scheme for a given user for a specific "app" that
|
|
8
|
+
* Retrieve auth keys for a specific security scheme for a given user for a specific "app" that
|
|
9
|
+
* they have configured.
|
|
9
10
|
*
|
|
10
|
-
* For `scheme` we're typing it to a union of `SecurityScheme` and `any` because we have handling
|
|
11
|
-
* unknown or unrecognized `type` and though it's not possible with the
|
|
12
|
-
* still be possible to get an unrecognized scheme
|
|
13
|
-
*
|
|
11
|
+
* For `scheme` we're typing it to a union of `SecurityScheme` and `any` because we have handling
|
|
12
|
+
* and tests for an unknown or unrecognized `type` and though it's not possible with the
|
|
13
|
+
* `SecurityScheme.type` to be unrecognized it may still be possible to get an unrecognized scheme
|
|
14
|
+
* with this method in the wild as we have API definitions in our database that were ingested
|
|
15
|
+
* before we had good validation in place.
|
|
14
16
|
*
|
|
15
17
|
* @param user User
|
|
16
18
|
* @param scheme Security scheme to get auth keys for.
|
|
@@ -18,7 +20,8 @@ declare type authKey = null | unknown | {
|
|
|
18
20
|
*/
|
|
19
21
|
export declare function getByScheme(user: RMOAS.User, scheme?: RMOAS.KeyedSecuritySchemeObject, selectedApp?: string | number): authKey;
|
|
20
22
|
/**
|
|
21
|
-
* Retrieve auth keys for an API definition from a given user for a specific "app" that they have
|
|
23
|
+
* Retrieve auth keys for an API definition from a given user for a specific "app" that they have
|
|
24
|
+
* configured.
|
|
22
25
|
*
|
|
23
26
|
* @param api API definition
|
|
24
27
|
* @param user User
|
|
@@ -6,9 +6,9 @@ export declare type MediaTypeExample = {
|
|
|
6
6
|
value: unknown;
|
|
7
7
|
};
|
|
8
8
|
/**
|
|
9
|
-
* Extracts a collection of examples from an OpenAPI Media Type Object. The example will either
|
|
10
|
-
* property, the first item in an `examples` array, or if none of those are
|
|
11
|
-
* off its schema.
|
|
9
|
+
* Extracts a collection of examples from an OpenAPI Media Type Object. The example will either
|
|
10
|
+
* come from the `example` property, the first item in an `examples` array, or if none of those are
|
|
11
|
+
* present it will generate an example based off its schema.
|
|
12
12
|
*
|
|
13
13
|
* @see {@link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#mediaTypeObject}
|
|
14
14
|
* @see {@link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#mediaTypeObject}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as RMOAS from '../rmoas.types';
|
|
2
2
|
declare type PrevSchemasType = RMOAS.SchemaObject[];
|
|
3
|
-
export declare type
|
|
3
|
+
export declare type toJSONSchemaOptions = {
|
|
4
|
+
addEnumsToDescriptions?: boolean;
|
|
4
5
|
currentLocation?: string;
|
|
5
6
|
globalDefaults?: Record<string, unknown>;
|
|
6
7
|
isPolymorphicAllOfChild?: boolean;
|
|
@@ -10,29 +11,34 @@ export declare type toJsonSchemaOptions = {
|
|
|
10
11
|
export declare function getSchemaVersionString(schema: RMOAS.SchemaObject, api: RMOAS.OASDocument): string;
|
|
11
12
|
export declare function isPrimitive(val: unknown): boolean;
|
|
12
13
|
/**
|
|
13
|
-
* Given an OpenAPI-flavored JSON Schema, make an effort to modify it so it's shaped more towards
|
|
14
|
+
* Given an OpenAPI-flavored JSON Schema, make an effort to modify it so it's shaped more towards
|
|
15
|
+
* stock JSON Schema.
|
|
14
16
|
*
|
|
15
17
|
* Why do this?
|
|
16
18
|
*
|
|
17
|
-
* 1. OpenAPI 3.0.x supports its own flavor of JSON Schema that isn't fully compatible with most
|
|
18
|
-
* (like `@readme/oas-form` or `@rjsf/core`).
|
|
19
|
-
* 2. While validating an OpenAPI definition will prevent corrupted or improper schemas from
|
|
20
|
-
* legacy schemas in ReadMe that were ingested before we had proper
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
19
|
+
* 1. OpenAPI 3.0.x supports its own flavor of JSON Schema that isn't fully compatible with most
|
|
20
|
+
* JSON Schema tooling (like `@readme/oas-form` or `@rjsf/core`).
|
|
21
|
+
* 2. While validating an OpenAPI definition will prevent corrupted or improper schemas from
|
|
22
|
+
* occuring, we have a lot of legacy schemas in ReadMe that were ingested before we had proper
|
|
23
|
+
* validation in place, and as a result have some API definitions that will not pass validation
|
|
24
|
+
* right now. In addition to reshaping OAS-JSON Schema into JSON Schema this library will also
|
|
25
|
+
* fix these improper schemas: things like `type: object` having `items` instead of `properties`,
|
|
26
|
+
* or `type: array` missing `items`.
|
|
27
|
+
* 3. To ease the burden of polymorphic handling on our form rendering engine we make an attempt
|
|
28
|
+
* to merge `allOf` schemas here.
|
|
29
|
+
* 4. Additionally due to OpenAPI 3.0.x not supporting JSON Schema, in order to support the
|
|
30
|
+
* `example` keyword that OAS supports, we need to do some work in here to remap it into
|
|
31
|
+
* `examples`. However, since all we care about in respect to examples for usage within
|
|
32
|
+
* `@readme/oas-form`, we're only retaining primitives. This *slightly* deviates from JSON
|
|
33
|
+
* Schema in that JSON Schema allows for any schema to be an example, but since
|
|
34
|
+
* `@readme/oas-form` can only actually **render** primitives, that's what we're retaining.
|
|
35
|
+
* 5. Though OpenAPI 3.1 does support full JSON Schema, this library should be able to handle it
|
|
36
|
+
* without any problems.
|
|
32
37
|
*
|
|
33
|
-
* And why use this over `@openapi-contrib/openapi-schema-to-json-schema`? Fortunately and
|
|
34
|
-
* of API definitions in our database that aren't currently valid so
|
|
35
|
-
* quirks, typos, and missing declarations that
|
|
38
|
+
* And why use this over `@openapi-contrib/openapi-schema-to-json-schema`? Fortunately and
|
|
39
|
+
* unfortunately we've got a lot of API definitions in our database that aren't currently valid so
|
|
40
|
+
* we need to have a lot of bespoke handling for odd quirks, typos, and missing declarations that
|
|
41
|
+
* might be present.
|
|
36
42
|
*
|
|
37
43
|
* @todo add support for `schema: false` and `not` cases.
|
|
38
44
|
* @see {@link https://json-schema.org/draft/2019-09/json-schema-validation.html}
|
|
@@ -40,11 +46,12 @@ export declare function isPrimitive(val: unknown): boolean;
|
|
|
40
46
|
* @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#schemaObject}
|
|
41
47
|
* @param data OpenAPI Schema Object to convert to pure JSON Schema.
|
|
42
48
|
* @param opts Options
|
|
49
|
+
* @param opts.addEnumsToDescriptions Whether or not to extend descriptions with a list of any present enums.
|
|
43
50
|
* @param opts.currentLocation Current location within the schema -- this is a JSON pointer.
|
|
44
51
|
* @param opts.globalDefaults Object containing a global set of defaults that we should apply to schemas that match it.
|
|
45
52
|
* @param opts.isPolymorphicAllOfChild Is this schema the child of a polymorphic `allOf` schema?
|
|
46
53
|
* @param opts.prevSchemas Array of parent schemas to utilize when attempting to path together examples.
|
|
47
54
|
* @param opts.refLogger A function that's called anytime a (circular) `$ref` is found.
|
|
48
55
|
*/
|
|
49
|
-
export default function toJSONSchema(data: RMOAS.SchemaObject | boolean, opts?:
|
|
56
|
+
export default function toJSONSchema(data: RMOAS.SchemaObject | boolean, opts?: toJSONSchemaOptions): RMOAS.SchemaObject;
|
|
50
57
|
export {};
|
|
@@ -6,7 +6,8 @@ export declare type CallbackExamples = {
|
|
|
6
6
|
example: unknown;
|
|
7
7
|
}[];
|
|
8
8
|
/**
|
|
9
|
-
* With an OpenAPI Operation Object return back a collection of examples for any callbacks that may
|
|
9
|
+
* With an OpenAPI Operation Object return back a collection of examples for any callbacks that may
|
|
10
|
+
* be present.
|
|
10
11
|
*
|
|
11
12
|
* @param operation Operation to retrieve callback examples from.
|
|
12
13
|
*/
|
|
@@ -8,7 +8,8 @@ export declare type SchemaWrapper = {
|
|
|
8
8
|
deprecatedProps?: SchemaWrapper;
|
|
9
9
|
};
|
|
10
10
|
/**
|
|
11
|
-
* The order of this object determines how they will be sorted in the compiled JSON Schema
|
|
11
|
+
* The order of this object determines how they will be sorted in the compiled JSON Schema
|
|
12
|
+
* representation.
|
|
12
13
|
*
|
|
13
14
|
* @see {@link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#parameterObject}
|
|
14
15
|
* @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#parameterObject}
|
package/@types/operation.d.ts
CHANGED
|
@@ -52,28 +52,29 @@ export default class Operation {
|
|
|
52
52
|
isJson(): boolean;
|
|
53
53
|
isXml(): boolean;
|
|
54
54
|
/**
|
|
55
|
-
* Returns an array of all security requirements associated wtih this operation. If none are
|
|
56
|
-
* level, the securities for the entire API definition are returned
|
|
55
|
+
* Returns an array of all security requirements associated wtih this operation. If none are
|
|
56
|
+
* defined at the operation level, the securities for the entire API definition are returned
|
|
57
|
+
* (with an empty array as a final fallback).
|
|
57
58
|
*
|
|
58
59
|
*/
|
|
59
60
|
getSecurity(): RMOAS.SecurityRequirementObject[];
|
|
60
61
|
/**
|
|
61
|
-
* Retrieve a collection of grouped security schemes. The inner array determines and-grouped
|
|
62
|
-
* outer array determines or-groups.
|
|
62
|
+
* Retrieve a collection of grouped security schemes. The inner array determines and-grouped
|
|
63
|
+
* security schemes, the outer array determines or-groups.
|
|
63
64
|
*
|
|
64
65
|
* @see {@link https://swagger.io/docs/specification/authentication/#multiple}
|
|
65
66
|
* @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#security-requirement-object}
|
|
66
67
|
* @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#securityRequirementObject}
|
|
67
|
-
* @param filterInvalid Optional flag that, when set to `true`, filters out invalid/nonexistent
|
|
68
|
-
* rather than returning `false`.
|
|
68
|
+
* @param filterInvalid Optional flag that, when set to `true`, filters out invalid/nonexistent
|
|
69
|
+
* security schemes, rather than returning `false`.
|
|
69
70
|
*/
|
|
70
71
|
getSecurityWithTypes(filterInvalid?: boolean): (false | (false | {
|
|
71
72
|
security: RMOAS.KeyedSecuritySchemeObject;
|
|
72
73
|
type: SecurityType;
|
|
73
74
|
})[])[];
|
|
74
75
|
/**
|
|
75
|
-
* Retrieve an object where the keys are unique scheme types, and the values are arrays
|
|
76
|
-
* scheme of that type.
|
|
76
|
+
* Retrieve an object where the keys are unique scheme types, and the values are arrays
|
|
77
|
+
* containing each security scheme of that type.
|
|
77
78
|
*
|
|
78
79
|
*/
|
|
79
80
|
prepareSecurity(): Record<SecurityType, RMOAS.KeyedSecuritySchemeObject[]>;
|
|
@@ -120,8 +121,8 @@ export default class Operation {
|
|
|
120
121
|
*/
|
|
121
122
|
hasRequiredParameters(): boolean;
|
|
122
123
|
/**
|
|
123
|
-
* Convert the operation into an array of JSON Schema schemas for each available type of
|
|
124
|
-
* operation.
|
|
124
|
+
* Convert the operation into an array of JSON Schema schemas for each available type of
|
|
125
|
+
* parameter available on the operation.
|
|
125
126
|
*
|
|
126
127
|
* @param opts
|
|
127
128
|
* @param opts.globalDefaults Contains an object of user defined schema defaults.
|
|
@@ -172,9 +173,10 @@ export default class Operation {
|
|
|
172
173
|
/**
|
|
173
174
|
* Retrieve a specific request body content schema off this operation.
|
|
174
175
|
*
|
|
175
|
-
* If no media type is supplied this will return either the first available JSON-like request
|
|
176
|
-
* available if there are no JSON-like media types present. When this return
|
|
177
|
-
* with the first key being the selected media type,
|
|
176
|
+
* If no media type is supplied this will return either the first available JSON-like request
|
|
177
|
+
* body, or the first available if there are no JSON-like media types present. When this return
|
|
178
|
+
* comes back it's in the form of an array with the first key being the selected media type,
|
|
179
|
+
* followed by the media type object in question.
|
|
178
180
|
*
|
|
179
181
|
* @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#mediaTypeObject}
|
|
180
182
|
* @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#mediaTypeObject}
|
|
@@ -7,8 +7,9 @@
|
|
|
7
7
|
import type * as RMOAS from '../rmoas.types';
|
|
8
8
|
import memoize from 'memoizee';
|
|
9
9
|
/**
|
|
10
|
-
* Generate a piece of sample data from a JSON Schema object. If `example` declarations are present
|
|
11
|
-
* utilized, but generally this will generate fake data for the information present in
|
|
10
|
+
* Generate a piece of sample data from a JSON Schema object. If `example` declarations are present
|
|
11
|
+
* they will be utilized, but generally this will generate fake data for the information present in
|
|
12
|
+
* the schema.
|
|
12
13
|
*
|
|
13
14
|
* @param schema JSON Schema to generate a sample for.
|
|
14
15
|
* @param opts Options
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
## <small>18.3.1 (2022-04-26)</small>
|
|
2
|
+
|
|
3
|
+
* chore(deps): bumping out of date deps to get rid of node 18 compat issues (#639) ([13703c8](https://github.com/readmeio/oas/commit/13703c8)), closes [#639](https://github.com/readmeio/oas/issues/639)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
1
7
|
## <small>18.2.2 (2022-04-11)</small>
|
|
2
8
|
|
|
3
9
|
* fix: stop rewriting operationIds when we don't need to (#635) ([996cd40](https://github.com/readmeio/oas/commit/996cd40)), closes [#635](https://github.com/readmeio/oas/issues/635)
|