oas 14.8.1 → 16.0.2
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 +141 -0
- package/@types/lib/find-schema-definition.d.ts +1 -0
- package/@types/lib/get-auth.d.ts +19 -0
- package/@types/lib/get-mediatype-examples.d.ts +2 -0
- package/@types/lib/get-schema.d.ts +2 -0
- package/@types/lib/get-user-variable.d.ts +2 -0
- package/@types/lib/matches-mimetype.d.ts +5 -0
- package/@types/lib/openapi-to-json-schema.d.ts +51 -0
- package/@types/operation/get-callback-examples.d.ts +2 -0
- package/@types/operation/get-parameters-as-json-schema.d.ts +13 -0
- package/@types/operation/get-requestbody-examples.d.ts +5 -0
- package/@types/operation/get-response-as-json-schema.d.ts +6 -0
- package/@types/operation/get-response-examples.d.ts +5 -0
- package/@types/operation.d.ts +175 -0
- package/@types/samples/index.d.ts +1 -0
- package/@types/samples/utils.d.ts +5 -0
- package/@types/utils.d.ts +21 -0
- package/CHANGELOG.md +55 -0
- package/README.md +1 -1
- package/dist/index.js +650 -2
- package/dist/lib/find-schema-definition.js +29 -0
- package/dist/lib/get-auth.js +57 -0
- package/dist/lib/get-mediatype-examples.js +69 -0
- package/dist/lib/get-schema.js +28 -0
- package/dist/lib/get-user-variable.js +13 -0
- package/dist/lib/matches-mimetype.js +29 -0
- package/dist/lib/openapi-to-json-schema.js +474 -0
- package/dist/operation/get-callback-examples.js +24 -0
- package/dist/operation/get-parameters-as-json-schema.js +274 -0
- package/dist/operation/get-requestbody-examples.js +25 -0
- package/dist/operation/get-response-as-json-schema.js +100 -0
- package/dist/operation/get-response-examples.js +32 -0
- package/dist/operation.js +455 -0
- package/dist/samples/index.js +129 -0
- package/dist/samples/utils.js +68 -0
- package/dist/utils.js +15 -0
- package/package.json +14 -34
- package/src/cli/commands/endpoint.js +4 -4
- package/src/cli/commands/help.js +8 -6
- package/src/cli/commands/init.js +8 -6
- package/src/cli/commands/validate.js +2 -2
- package/src/cli/index.js +3 -2
- package/src/cli/lib/utils.js +22 -26
- package/src/index.js +119 -11
- package/src/lib/{find-schema-definition.js → find-schema-definition.ts} +2 -4
- package/src/lib/get-auth.ts +88 -0
- package/src/lib/get-mediatype-examples.js +1 -1
- package/src/lib/get-schema.js +1 -1
- package/src/lib/openapi-to-json-schema.js +7 -7
- package/src/operation/get-callback-examples.js +30 -0
- package/src/operation/get-response-as-json-schema.js +1 -1
- package/src/operation.js +103 -8
- package/src/samples/index.js +1 -1
- package/src/samples/utils.js +1 -1
- package/src/utils.ts +11 -0
- package/tsconfig.json +15 -0
- package/tsconfig.test.json +8 -0
- package/dist/index.js.LICENSE.txt +0 -26
- package/src/lib/flatten-array.js +0 -5
- package/src/lib/flatten-schema.js +0 -146
- package/src/lib/get-auth.js +0 -56
- package/src/lib/get-path-operation.js +0 -12
- package/src/lib/get-path.js +0 -7
- package/src/utils.js +0 -15
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
export = Oas;
|
|
2
|
+
declare class Oas {
|
|
3
|
+
constructor(oas: any, user: any);
|
|
4
|
+
user: any;
|
|
5
|
+
_promises: any[];
|
|
6
|
+
_dereferencing: {
|
|
7
|
+
processing: boolean;
|
|
8
|
+
complete: boolean;
|
|
9
|
+
};
|
|
10
|
+
getVersion(): any;
|
|
11
|
+
url(selected: number, variables: any): any;
|
|
12
|
+
variables(selected?: number): any;
|
|
13
|
+
defaultVariables(selected?: number): {};
|
|
14
|
+
splitUrl(selected?: number): any;
|
|
15
|
+
/**
|
|
16
|
+
* With a fully composed server URL, run through our list of known OAS servers and return back which server URL was
|
|
17
|
+
* selected along with any contained server variables split out.
|
|
18
|
+
*
|
|
19
|
+
* For example, if you have an OAS server URL of `https://{name}.example.com:{port}/{basePath}`, and pass in
|
|
20
|
+
* `https://buster.example.com:3000/pet` to this function, you'll get back the following:
|
|
21
|
+
*
|
|
22
|
+
* { selected: 0, variables: { name: 'buster', port: 3000, basePath: 'pet' } }
|
|
23
|
+
*
|
|
24
|
+
* Re-supplying this data to `oas.url()` should return the same URL you passed into this method.
|
|
25
|
+
*
|
|
26
|
+
* @param {String} baseUrl
|
|
27
|
+
* @returns {Object|Boolean}
|
|
28
|
+
*/
|
|
29
|
+
splitVariables(baseUrl: string): Object | boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Replace templated variables with supplied data in a given URL.
|
|
32
|
+
*
|
|
33
|
+
* There are a couple ways that this will utilize variable data:
|
|
34
|
+
*
|
|
35
|
+
* - If data is stored in `this.user` and it matches up with the variable name in the URL user data
|
|
36
|
+
* will always take priority. See `getUserVariable` for some more information on how this data is pulled from
|
|
37
|
+
* `this.user`.
|
|
38
|
+
* - Supplying a `variables` object. This incoming `variables` object can be two formats:
|
|
39
|
+
* `{ variableName: { default: 'value' } }` and `{ variableName: 'value' }`. If the former is present, that will
|
|
40
|
+
* take prescendence over the latter.
|
|
41
|
+
*
|
|
42
|
+
* If no variables supplied match up with the template name, the template name will instead be used as the variable
|
|
43
|
+
* data.
|
|
44
|
+
*
|
|
45
|
+
* @param {String} url
|
|
46
|
+
* @param {Object} variables
|
|
47
|
+
* @returns String
|
|
48
|
+
*/
|
|
49
|
+
replaceUrl(url: string, variables?: Object): any;
|
|
50
|
+
operation(path: any, method: any, opts?: {}): Operation.Webhook | Operation;
|
|
51
|
+
findOperationMatches(url: any): {
|
|
52
|
+
url: {
|
|
53
|
+
origin: any;
|
|
54
|
+
path: any;
|
|
55
|
+
nonNormalizedPath: string;
|
|
56
|
+
slugs: {};
|
|
57
|
+
};
|
|
58
|
+
operation: any;
|
|
59
|
+
match: import("path-to-regexp").Match<object>;
|
|
60
|
+
}[];
|
|
61
|
+
/**
|
|
62
|
+
* Discover an operation in an OAS from a fully-formed URL and HTTP method. Will return an object containing a `url`
|
|
63
|
+
* object and another one for `operation`. This differs from `getOperation()` in that it does not return an instance
|
|
64
|
+
* of the `Operation` class.
|
|
65
|
+
*
|
|
66
|
+
* @param {String} url
|
|
67
|
+
* @param {String} method
|
|
68
|
+
* @return {(Object|undefined)}
|
|
69
|
+
*/
|
|
70
|
+
findOperation(url: string, method: string): (Object | undefined);
|
|
71
|
+
/**
|
|
72
|
+
* Discover an operation in an OAS from a fully-formed URL without an HTTP method. Will return an object containing a `url`
|
|
73
|
+
* object and another one for `operation`.
|
|
74
|
+
*
|
|
75
|
+
* @param {String} url
|
|
76
|
+
* @return {(Object|undefined)}
|
|
77
|
+
*/
|
|
78
|
+
findOperationWithoutMethod(url: string): (Object | undefined);
|
|
79
|
+
/**
|
|
80
|
+
* Retrieve an operation in an OAS from a fully-formed URL and HTTP method. Differs from `findOperation` in that while
|
|
81
|
+
* this method will return an `Operation` instance, `findOperation()` does not.
|
|
82
|
+
*
|
|
83
|
+
* @param {String} url
|
|
84
|
+
* @param {String} method
|
|
85
|
+
* @return {(Operation|undefined)}
|
|
86
|
+
*/
|
|
87
|
+
getOperation(url: string, method: string): (Operation | undefined);
|
|
88
|
+
/**
|
|
89
|
+
* With an object of user information, retrieve an appropriate API key from the current OAS definition.
|
|
90
|
+
*
|
|
91
|
+
* @see {@link https://docs.readme.com/docs/passing-data-to-jwt}
|
|
92
|
+
* @param {Object} user
|
|
93
|
+
* @param {Boolean|String} selectedApp
|
|
94
|
+
*/
|
|
95
|
+
getAuth(user: Object, selectedApp?: boolean | string): Record<string, unknown>;
|
|
96
|
+
/**
|
|
97
|
+
* Returns the `paths` object that exists in this API definition but with every `method` mapped to an instance of
|
|
98
|
+
* the `Operation` class.
|
|
99
|
+
*
|
|
100
|
+
* @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.0.md#oasObject}
|
|
101
|
+
* @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#openapi-object}
|
|
102
|
+
* @returns {object}
|
|
103
|
+
*/
|
|
104
|
+
getPaths(): object;
|
|
105
|
+
/**
|
|
106
|
+
* Returns the `webhooks` object that exists in this API definition but with every `method` mapped to an instance of
|
|
107
|
+
* the `Operation` class.
|
|
108
|
+
*
|
|
109
|
+
* @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.0.md#oasObject}
|
|
110
|
+
* @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#openapi-object}
|
|
111
|
+
* @returns {object}
|
|
112
|
+
*/
|
|
113
|
+
getWebhooks(): object;
|
|
114
|
+
/**
|
|
115
|
+
* Return an array of all tag names that exist on this API definition.
|
|
116
|
+
*
|
|
117
|
+
* Note: This method right now does **not** factor in webhooks that have tags.
|
|
118
|
+
*
|
|
119
|
+
* @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.0.md#oasObject}
|
|
120
|
+
* @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#openapi-object}
|
|
121
|
+
* @param {boolean} setIfMissing If a tag is not present on an operation that operations path will be added into the
|
|
122
|
+
* list of tags returned.
|
|
123
|
+
* @returns {array}
|
|
124
|
+
*/
|
|
125
|
+
getTags(setIfMissing?: boolean): any;
|
|
126
|
+
/**
|
|
127
|
+
* Dereference the current OAS definition so it can be parsed free of worries of `$ref` schemas and circular
|
|
128
|
+
* structures.
|
|
129
|
+
*
|
|
130
|
+
* @returns {Promise<void>}
|
|
131
|
+
*/
|
|
132
|
+
dereference(): Promise<void>;
|
|
133
|
+
}
|
|
134
|
+
declare namespace Oas {
|
|
135
|
+
export { Operation, Callback, Webhook, utils };
|
|
136
|
+
}
|
|
137
|
+
import Operation = require("./operation");
|
|
138
|
+
import { Callback } from "./operation";
|
|
139
|
+
import { Webhook } from "./operation";
|
|
140
|
+
import utils_1 = require("./utils");
|
|
141
|
+
import utils = utils_1.default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function findSchemaDefinition($ref: string, definitions?: {}): false | any;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { OpenAPIV3, OpenAPIV3_1 } from 'openapi-types';
|
|
2
|
+
declare type primitiveType = string | number;
|
|
3
|
+
declare type selectedAppType = primitiveType;
|
|
4
|
+
declare type authKey = null | unknown | {
|
|
5
|
+
user: primitiveType;
|
|
6
|
+
password: primitiveType;
|
|
7
|
+
};
|
|
8
|
+
interface User {
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
keys?: Array<{
|
|
11
|
+
name: string;
|
|
12
|
+
user?: primitiveType;
|
|
13
|
+
pass?: primitiveType;
|
|
14
|
+
[key: string]: unknown;
|
|
15
|
+
}>;
|
|
16
|
+
}
|
|
17
|
+
declare function getByScheme(user: User, scheme?: any, selectedApp?: selectedAppType): authKey;
|
|
18
|
+
export { getByScheme };
|
|
19
|
+
export default function getAuth(oas: OpenAPIV3.Document | OpenAPIV3_1.Document, user: User, selectedApp?: selectedAppType): Record<string, unknown>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export = toJSONSchema;
|
|
2
|
+
/**
|
|
3
|
+
* Given an OpenAPI-flavored JSON Schema, make an effort to modify it so it's shaped more towards stock JSON Schema.
|
|
4
|
+
*
|
|
5
|
+
* Why do this?
|
|
6
|
+
*
|
|
7
|
+
* 1. OpenAPI 3.0.x supports its own flavor of JSON Schema that isn't fully compatible with most JSON Schema tooling
|
|
8
|
+
* (like `@readme/oas-form` or `@rjsf/core`).
|
|
9
|
+
* 2. While validating an OpenAPI definition will prevent corrupted or improper schemas from occuring, we have a lot of
|
|
10
|
+
* legacy schemas in ReadMe that were ingested before we had proper validation in place, and as a result have some
|
|
11
|
+
* API definitions that will not pass validation right now. In addition to reshaping OAS-JSON Schema into JSON Schema
|
|
12
|
+
* this library will also fix these improper schemas: things like `type: object` having `items` instead of
|
|
13
|
+
* `properties`, `type: array` missing `items`, or `type` missing completely on a schema.
|
|
14
|
+
* 3. Additionally due to OpenAPI 3.0.x not supporting JSON Schema, in order to support the `example` keyword that OAS
|
|
15
|
+
* supports, we need to do some work in here to remap it into `examples`. However, since all we care about in respect
|
|
16
|
+
* to examples for usage within `@readme/oas-form`, we're only retaining primitives. This *slightly* deviates from
|
|
17
|
+
* JSON Schema in that JSON Schema allows for any schema to be an example, but since `@readme/oas-form` can only
|
|
18
|
+
* actually **render** primitives, that's what we're retaining.
|
|
19
|
+
* 4. Though OpenAPI 3.1 does support full JSON Schema, this library should be able to handle it without any problems.
|
|
20
|
+
*
|
|
21
|
+
* And why use this over `@openapi-contrib/openapi-schema-to-json-schema`? Fortunately and unfortunately we've got a lot
|
|
22
|
+
* of API definitions in our database that aren't currently valid so we need to have a lot of bespoke handling for odd
|
|
23
|
+
* quirks, typos, and missing declarations that they've got.
|
|
24
|
+
*
|
|
25
|
+
* @see {@link https://json-schema.org/draft/2019-09/json-schema-validation.html{}
|
|
26
|
+
* @see {@link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md}
|
|
27
|
+
* @param {Object} data
|
|
28
|
+
* @param {Object} opts
|
|
29
|
+
* @param {String} opts.currentLocation - Current location within the schema -- this is a JSON pointer.
|
|
30
|
+
* @param {Object} opts.globalDefaults - Object containing a global set of defaults that we should apply to schemas that match it.
|
|
31
|
+
* @param {Boolean} opts.isPolymorphicAllOfChild - Is this schema the child of a polymorphic `allOf` schema?
|
|
32
|
+
* @param {Object[]} opts.prevSchemas - Array of parent schemas to utilize when attempting to path together examples.
|
|
33
|
+
* @param {Function} opts.refLogger - A function that's called anytime a (circular) `$ref` is found.
|
|
34
|
+
*/
|
|
35
|
+
declare function toJSONSchema(data: Object, opts?: {
|
|
36
|
+
currentLocation: string;
|
|
37
|
+
globalDefaults: Object;
|
|
38
|
+
isPolymorphicAllOfChild: boolean;
|
|
39
|
+
prevSchemas: Object[];
|
|
40
|
+
refLogger: Function;
|
|
41
|
+
}): {
|
|
42
|
+
constructor: Function;
|
|
43
|
+
toString(): string;
|
|
44
|
+
toLocaleString(): string;
|
|
45
|
+
valueOf(): Object;
|
|
46
|
+
hasOwnProperty(v: PropertyKey): boolean;
|
|
47
|
+
isPrototypeOf(v: Object): boolean;
|
|
48
|
+
propertyIsEnumerable(v: PropertyKey): boolean;
|
|
49
|
+
} | {
|
|
50
|
+
$ref: any;
|
|
51
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare function _exports(path: string, operation: any, oas: any, globalDefaults?: Object): any;
|
|
2
|
+
declare namespace _exports {
|
|
3
|
+
export { types };
|
|
4
|
+
}
|
|
5
|
+
export = _exports;
|
|
6
|
+
declare namespace types {
|
|
7
|
+
const path: string;
|
|
8
|
+
const query: string;
|
|
9
|
+
const body: string;
|
|
10
|
+
const cookie: string;
|
|
11
|
+
const formData: string;
|
|
12
|
+
const header: string;
|
|
13
|
+
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
export = Operation;
|
|
2
|
+
declare class Operation {
|
|
3
|
+
constructor(oas: any, path: any, method: any, operation: any);
|
|
4
|
+
schema: any;
|
|
5
|
+
oas: any;
|
|
6
|
+
path: any;
|
|
7
|
+
method: any;
|
|
8
|
+
contentType: any;
|
|
9
|
+
requestBodyExamples: (false | {
|
|
10
|
+
mediaType: string;
|
|
11
|
+
examples: any;
|
|
12
|
+
})[];
|
|
13
|
+
responseExamples: (false | {
|
|
14
|
+
status: string;
|
|
15
|
+
mediaTypes: {};
|
|
16
|
+
})[];
|
|
17
|
+
callbackExamples: any[];
|
|
18
|
+
getContentType(): any;
|
|
19
|
+
isFormUrlEncoded(): any;
|
|
20
|
+
isMultipart(): any;
|
|
21
|
+
isJson(): any;
|
|
22
|
+
isXml(): any;
|
|
23
|
+
/**
|
|
24
|
+
* Returns an array of all security requirements associated wtih this operation. If none are defined at the operation
|
|
25
|
+
* level, the securities for the entire API definition are returned (with an empty array as a final fallback).
|
|
26
|
+
*
|
|
27
|
+
* @returns {array}
|
|
28
|
+
*/
|
|
29
|
+
getSecurity(): any;
|
|
30
|
+
/**
|
|
31
|
+
* @see {@link https://swagger.io/docs/specification/authentication/#multiple}
|
|
32
|
+
* @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#security-requirement-object}
|
|
33
|
+
* @param {boolean} filterInvalid Optional flag that, when set to `true`, filters out invalid/nonexistent security
|
|
34
|
+
* schemes, rather than returning `false`.
|
|
35
|
+
* @returns {array} An array of arrays of objects of grouped security schemes. The inner array determines and-grouped
|
|
36
|
+
* security schemes, the outer array determines or-groups.
|
|
37
|
+
*/
|
|
38
|
+
getSecurityWithTypes(filterInvalid?: boolean): any;
|
|
39
|
+
/**
|
|
40
|
+
* @returns An object where the keys are unique scheme types,
|
|
41
|
+
* and the values are arrays containing each security scheme of that type.
|
|
42
|
+
*/
|
|
43
|
+
prepareSecurity(): any;
|
|
44
|
+
getHeaders(): {
|
|
45
|
+
request: any[];
|
|
46
|
+
response: any[];
|
|
47
|
+
};
|
|
48
|
+
headers: {
|
|
49
|
+
request: any[];
|
|
50
|
+
response: any[];
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Determine if the operation has an operation present in its schema.
|
|
54
|
+
*
|
|
55
|
+
* @return {boolean}
|
|
56
|
+
*/
|
|
57
|
+
hasOperationId(): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Get an `operationId` for this operation. If one is not present (it's not required by the spec!) a hash of the path
|
|
60
|
+
* and method will be returned instead.
|
|
61
|
+
*
|
|
62
|
+
* @return {string}
|
|
63
|
+
*/
|
|
64
|
+
getOperationId(): string;
|
|
65
|
+
/**
|
|
66
|
+
* Return an array of all tags, and their metadata, that exist on this operation.
|
|
67
|
+
*
|
|
68
|
+
* @returns {array}
|
|
69
|
+
*/
|
|
70
|
+
getTags(): any;
|
|
71
|
+
/**
|
|
72
|
+
* Return is the operation is flagged as `deprecated` or not.
|
|
73
|
+
*
|
|
74
|
+
* @returns {boolean}
|
|
75
|
+
*/
|
|
76
|
+
isDeprecated(): boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Return the parameters (non-request body) on the operation.
|
|
79
|
+
*
|
|
80
|
+
* @todo This should also pull in common params.
|
|
81
|
+
* @return {array}
|
|
82
|
+
*/
|
|
83
|
+
getParameters(): any;
|
|
84
|
+
/**
|
|
85
|
+
* Convert the operation into an array of JSON Schema for each available type of parameter available on the operation.
|
|
86
|
+
* `globalDefaults` contains an object of user defined parameter defaults used in constructSchema
|
|
87
|
+
*
|
|
88
|
+
* @param {Object} globalDefaults
|
|
89
|
+
* @return {array}
|
|
90
|
+
*/
|
|
91
|
+
getParametersAsJsonSchema(globalDefaults: Object): any;
|
|
92
|
+
/**
|
|
93
|
+
* Get a single response for this status code, formatted as JSON schema
|
|
94
|
+
* @param {*} statusCode
|
|
95
|
+
* @returns
|
|
96
|
+
*/
|
|
97
|
+
getResponseAsJsonSchema(statusCode: any): {
|
|
98
|
+
type: any;
|
|
99
|
+
schema: any;
|
|
100
|
+
label: string;
|
|
101
|
+
}[];
|
|
102
|
+
/**
|
|
103
|
+
* Get an array of all valid response status codes for this operation
|
|
104
|
+
* @param {*} statusCode
|
|
105
|
+
* @returns
|
|
106
|
+
*/
|
|
107
|
+
getResponseStatusCodes(): string[];
|
|
108
|
+
/**
|
|
109
|
+
* Determine if the operation has a request body.
|
|
110
|
+
*
|
|
111
|
+
* @return {boolean}
|
|
112
|
+
*/
|
|
113
|
+
hasRequestBody(): boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Retrieve an array of request body examples that this operation has.
|
|
116
|
+
*
|
|
117
|
+
* @returns {array}
|
|
118
|
+
*/
|
|
119
|
+
getRequestBodyExamples(): any;
|
|
120
|
+
/**
|
|
121
|
+
* Return a specific response out of the operation by a given HTTP status code.
|
|
122
|
+
*
|
|
123
|
+
* @param {integer} statusCode
|
|
124
|
+
* @return {(boolean|object)}
|
|
125
|
+
*/
|
|
126
|
+
getResponseByStatusCode(statusCode: any): (boolean | object);
|
|
127
|
+
/**
|
|
128
|
+
* Retrieve an array of response examples that this operation has.
|
|
129
|
+
*
|
|
130
|
+
* @returns {array}
|
|
131
|
+
*/
|
|
132
|
+
getResponseExamples(): any;
|
|
133
|
+
/**
|
|
134
|
+
* Determine if the operation has callbacks.
|
|
135
|
+
*
|
|
136
|
+
* @return {boolean}
|
|
137
|
+
*/
|
|
138
|
+
hasCallbacks(): boolean;
|
|
139
|
+
/**
|
|
140
|
+
* Retrieve a specific callback
|
|
141
|
+
*
|
|
142
|
+
* @returns {Operation}
|
|
143
|
+
*/
|
|
144
|
+
getCallback(identifier: any, expression: any, method: any): Operation;
|
|
145
|
+
/**
|
|
146
|
+
* Retrieve an array of operations created from each callback.
|
|
147
|
+
*
|
|
148
|
+
* @returns {array}
|
|
149
|
+
*/
|
|
150
|
+
getCallbacks(): any;
|
|
151
|
+
/**
|
|
152
|
+
* Retrieve an array of callback examples that this operation has.
|
|
153
|
+
*
|
|
154
|
+
* @returns {array}
|
|
155
|
+
*/
|
|
156
|
+
getCallbackExamples(): any;
|
|
157
|
+
}
|
|
158
|
+
declare namespace Operation {
|
|
159
|
+
export { Callback, Webhook };
|
|
160
|
+
}
|
|
161
|
+
declare class Callback extends Operation {
|
|
162
|
+
constructor(oas: any, path: any, method: any, operation: any, identifier: any);
|
|
163
|
+
identifier: any;
|
|
164
|
+
/**
|
|
165
|
+
* Return the primary identifier for this callback.
|
|
166
|
+
*
|
|
167
|
+
* @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#callback-object}
|
|
168
|
+
* @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#callbackObject}
|
|
169
|
+
*
|
|
170
|
+
* @returns {string}
|
|
171
|
+
*/
|
|
172
|
+
getIdentifier(): string;
|
|
173
|
+
}
|
|
174
|
+
declare class Webhook extends Operation {
|
|
175
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export var sampleFromSchema: any;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export function usesPolymorphism(schema: any): string;
|
|
2
|
+
export function objectify(thing: any): any;
|
|
3
|
+
export function normalizeArray(arr: any): any[];
|
|
4
|
+
export function isFunc(thing: any): boolean;
|
|
5
|
+
export function deeplyStripKey(input: any, keyToStrip: any, predicate?: () => boolean): any;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import findSchemaDefinition from './lib/find-schema-definition';
|
|
2
|
+
declare const _default: {
|
|
3
|
+
findSchemaDefinition: typeof findSchemaDefinition;
|
|
4
|
+
getSchema: (pathOperation: any, oas: any) => any;
|
|
5
|
+
jsonSchemaTypes: {
|
|
6
|
+
path: string;
|
|
7
|
+
query: string;
|
|
8
|
+
body: string;
|
|
9
|
+
cookie: string;
|
|
10
|
+
formData: string;
|
|
11
|
+
header: string;
|
|
12
|
+
};
|
|
13
|
+
matchesMimeType: {
|
|
14
|
+
formUrlEncoded: (contentType: any) => any;
|
|
15
|
+
json: (contentType: any) => any;
|
|
16
|
+
multipart: (contentType: any) => any;
|
|
17
|
+
wildcard: (contentType: any) => boolean;
|
|
18
|
+
xml: (contentType: any) => any;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export default _default;
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,58 @@
|
|
|
1
|
+
## <small>16.0.2 (2021-10-28)</small>
|
|
2
|
+
|
|
3
|
+
* fix: minor typescript cleanup ([f032a30](https://github.com/readmeio/oas/commit/f032a30))
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
## <small>16.0.1 (2021-10-28)</small>
|
|
8
|
+
|
|
9
|
+
* feat: exporting the internal `utils` library to the main export ([2eaeac7](https://github.com/readmeio/oas/commit/2eaeac7))
|
|
10
|
+
* chore: removing an unneeded eslint exclusion ([99151d3](https://github.com/readmeio/oas/commit/99151d3))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## 16.0.0 (2021-10-28)
|
|
15
|
+
|
|
16
|
+
> **BREAKING CHANGE**
|
|
17
|
+
>
|
|
18
|
+
> This library no longer ships with a browser-targeted dist. If you need to the tooling side of this library within a browser you'll need to handle bundling with your favorite tool for doing so.
|
|
19
|
+
|
|
20
|
+
* fix: removing webpack and a browser-targeted export (#529) ([a4e84c8](https://github.com/readmeio/oas/commit/a4e84c8)), closes [#529](https://github.com/readmeio/oas/issues/529)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
## 15.0.0 (2021-10-28)
|
|
25
|
+
|
|
26
|
+
> **BREAKING CHANGE**
|
|
27
|
+
>
|
|
28
|
+
> Lots of changes here!
|
|
29
|
+
>
|
|
30
|
+
> - We're starting a slow process to transition the library to Typescript so a couple sub-libraries here now have exposed Typescript declaration files.
|
|
31
|
+
> - The `flattenArray` and `flattenSchema` exports have been removed.
|
|
32
|
+
> - The primary entrypoint for the library has been moved from `src/` to `dist/` so if we don't export something you're using you'll likely have a tough time to access it. If you need something let us know and we'll add an export for it (we're also open to PR's!).
|
|
33
|
+
>
|
|
34
|
+
> We're also starting to adopt OpenAPI 3.1 and have access a heap of new accessors in the `Oas` and `Operation` classes as well as extending support for it immediately to the `oas validate` CLI command. 🥳
|
|
35
|
+
|
|
36
|
+
* feat: add callback accessors into operation class (#515) ([c1759bd](https://github.com/readmeio/oas/commit/c1759bd)), closes [#515](https://github.com/readmeio/oas/issues/515)
|
|
37
|
+
* feat: adding a `getIdentifier` accessor on the Callback class (#528) ([fb65142](https://github.com/readmeio/oas/commit/fb65142)), closes [#528](https://github.com/readmeio/oas/issues/528)
|
|
38
|
+
* feat: adding accessors for spec versions, paths, webhooks, and tags (#516) ([2daaf67](https://github.com/readmeio/oas/commit/2daaf67)), closes [#516](https://github.com/readmeio/oas/issues/516)
|
|
39
|
+
* feat: supporting OpenAPI 3.1 within the CLI tooling (#514) ([d1463b3](https://github.com/readmeio/oas/commit/d1463b3)), closes [#514](https://github.com/readmeio/oas/issues/514)
|
|
40
|
+
* feat: webpack 5 + typescript beginnings (#518) ([a59fd9b](https://github.com/readmeio/oas/commit/a59fd9b)), closes [#518](https://github.com/readmeio/oas/issues/518)
|
|
41
|
+
* chore(deps-dev): bump @babel/core from 7.15.5 to 7.15.8 (#527) ([b90d64e](https://github.com/readmeio/oas/commit/b90d64e)), closes [#527](https://github.com/readmeio/oas/issues/527)
|
|
42
|
+
* chore(deps-dev): bump @babel/preset-env from 7.15.6 to 7.15.8 (#526) ([e32b2ad](https://github.com/readmeio/oas/commit/e32b2ad)), closes [#526](https://github.com/readmeio/oas/issues/526)
|
|
43
|
+
* chore(deps-dev): bump @commitlint/cli from 13.2.0 to 13.2.1 (#522) ([b42ee68](https://github.com/readmeio/oas/commit/b42ee68)), closes [#522](https://github.com/readmeio/oas/issues/522)
|
|
44
|
+
* chore(deps-dev): bump babel-loader from 8.2.2 to 8.2.3 (#524) ([f57fea4](https://github.com/readmeio/oas/commit/f57fea4)), closes [#524](https://github.com/readmeio/oas/issues/524)
|
|
45
|
+
* chore(deps-dev): bump husky from 7.0.2 to 7.0.4 (#521) ([6ca7d93](https://github.com/readmeio/oas/commit/6ca7d93)), closes [#521](https://github.com/readmeio/oas/issues/521)
|
|
46
|
+
* chore(deps-dev): bump jest from 27.2.4 to 27.3.1 (#520) ([4c53b4b](https://github.com/readmeio/oas/commit/4c53b4b)), closes [#520](https://github.com/readmeio/oas/issues/520)
|
|
47
|
+
* chore(deps): bump actions/checkout from 2.3.4 to 2.3.5 (#519) ([bdd7c3c](https://github.com/readmeio/oas/commit/bdd7c3c)), closes [#519](https://github.com/readmeio/oas/issues/519)
|
|
48
|
+
* chore(deps): bump inquirer from 8.1.5 to 8.2.0 (#523) ([d675cbe](https://github.com/readmeio/oas/commit/d675cbe)), closes [#523](https://github.com/readmeio/oas/issues/523)
|
|
49
|
+
* chore(deps): bump swagger-inline from 4.2.1 to 4.2.2 (#525) ([60a9fa2](https://github.com/readmeio/oas/commit/60a9fa2)), closes [#525](https://github.com/readmeio/oas/issues/525)
|
|
50
|
+
* fix: adding a base undefined callbackExamples property to the Oas class ([0d5a233](https://github.com/readmeio/oas/commit/0d5a233))
|
|
51
|
+
* fix: deprecatedProps inherits parent schemas type (#517) ([b7277d3](https://github.com/readmeio/oas/commit/b7277d3)), closes [#517](https://github.com/readmeio/oas/issues/517)
|
|
52
|
+
* build: release 14.8.1 ([c9ce444](https://github.com/readmeio/oas/commit/c9ce444))
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
1
56
|
## 14.8.0 (2021-10-18)
|
|
2
57
|
|
|
3
58
|
* feat: separate deprecated params for display (#513) ([9817b3e](https://github.com/readmeio/oas/commit/9817b3e)), closes [#513](https://github.com/readmeio/oas/issues/513)
|
package/README.md
CHANGED
|
@@ -57,4 +57,4 @@ require('oas')
|
|
|
57
57
|
|
|
58
58
|
Also exposed within the main `oas` export is an `Operation` class that can help you manage and retrieve specific data from an API operation.
|
|
59
59
|
|
|
60
|
-
>
|
|
60
|
+
> If you need to use this library within a browser you'll likely need to use a bundler like [Webpack](https://webpack.js.org/) or [Rollup](https://rollupjs.org/).
|