genoc 0.4.3 → 0.5.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/dist/analyzer/analyze.js +69 -27
- package/dist/analyzer/path-analyzer.d.ts +3 -1
- package/dist/analyzer/path-analyzer.js +2 -1
- package/dist/analyzer/types.d.ts +25 -0
- package/dist/cli/impl.js +3 -1
- package/dist/generator/client-generator.js +64 -4
- package/dist/generator/contracts-generator.js +7 -0
- package/dist/generator/method-generator.d.ts +9 -1
- package/dist/generator/method-generator.js +26 -0
- package/dist/parser/spec-reader.js +6 -25
- package/dist/parser/version/spec-links.d.ts +55 -0
- package/dist/parser/version/spec-links.js +65 -0
- package/dist/parser/version/v3.0/validator.d.ts +3 -1
- package/dist/parser/version/v3.0/validator.js +23 -23
- package/dist/parser/version/v3.1/validator.d.ts +3 -1
- package/dist/parser/version/v3.1/validator.js +25 -23
- package/dist/parser/version/validate-info.d.ts +9 -0
- package/dist/parser/version/validate-info.js +22 -0
- package/dist/parser/version/validate-security.d.ts +17 -0
- package/dist/parser/version/validate-security.js +218 -0
- package/dist/parser/version/version-detector.js +27 -8
- package/dist/runtime/defined-errors.d.ts +3 -2
- package/dist/runtime/defined-errors.js +6 -3
- package/dist/runtime/errors.d.ts +1 -3
- package/dist/runtime/errors.js +2 -6
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/requester.d.ts +67 -0
- package/dist/types/openapi.d.ts +5 -4
- package/dist/utils/http-methods.d.ts +8 -0
- package/dist/utils/http-methods.js +17 -0
- package/dist/utils/operation-naming.js +1 -0
- package/package.json +1 -1
package/dist/runtime/index.d.ts
CHANGED
|
@@ -8,4 +8,4 @@
|
|
|
8
8
|
export { ApiError, UnspecifiedApiError, DefaultApiError, RequesterFailError } from './errors.js';
|
|
9
9
|
export { StreamResponse, ErrorResponse } from './responses.js';
|
|
10
10
|
export { decorateWithErrors, isDefinedError } from './defined-errors.js';
|
|
11
|
-
export type { Requester } from './requester.js';
|
|
11
|
+
export type { Requester, SecurityScheme, SecurityCall, SecurityRequirement, OAuthFlow, OAuthFlows, } from './requester.js';
|
|
@@ -1,14 +1,81 @@
|
|
|
1
1
|
import type { ErrorResponse, StreamResponse } from './responses.js';
|
|
2
|
+
/**
|
|
3
|
+
* OAuth 2.0 flow configuration, spec-agnostic structural twin of the OpenAPI
|
|
4
|
+
* OAuth Flow Object. Which URLs are meaningful depends on the flow kind.
|
|
5
|
+
*/
|
|
6
|
+
export type OAuthFlow = {
|
|
7
|
+
authorizationUrl?: string;
|
|
8
|
+
tokenUrl?: string;
|
|
9
|
+
refreshUrl?: string;
|
|
10
|
+
scopes: Record<string, string>;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* OAuth 2.0 flows, spec-agnostic structural twin of the OpenAPI OAuth Flows
|
|
14
|
+
* Object.
|
|
15
|
+
*/
|
|
16
|
+
export type OAuthFlows = {
|
|
17
|
+
implicit?: OAuthFlow;
|
|
18
|
+
password?: OAuthFlow;
|
|
19
|
+
clientCredentials?: OAuthFlow;
|
|
20
|
+
authorizationCode?: OAuthFlow;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Spec-agnostic structural twin of an OpenAPI security scheme object,
|
|
24
|
+
* discriminated on `type` so implementations can narrow.
|
|
25
|
+
*/
|
|
26
|
+
export type SecurityScheme = {
|
|
27
|
+
type: 'apiKey';
|
|
28
|
+
name: string;
|
|
29
|
+
in: string;
|
|
30
|
+
description?: string;
|
|
31
|
+
} | {
|
|
32
|
+
type: 'http';
|
|
33
|
+
scheme: string;
|
|
34
|
+
bearerFormat?: string;
|
|
35
|
+
description?: string;
|
|
36
|
+
} | {
|
|
37
|
+
type: 'oauth2';
|
|
38
|
+
flows: OAuthFlows;
|
|
39
|
+
description?: string;
|
|
40
|
+
} | {
|
|
41
|
+
type: 'openIdConnect';
|
|
42
|
+
openIdConnectUrl: string;
|
|
43
|
+
description?: string;
|
|
44
|
+
} | {
|
|
45
|
+
type: 'mutualTLS';
|
|
46
|
+
description?: string;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* One scheme invocation inside a security requirement: the scheme name as
|
|
50
|
+
* declared in the spec, the scopes requested for it, and the resolved scheme
|
|
51
|
+
* object.
|
|
52
|
+
*/
|
|
53
|
+
export type SecurityCall = {
|
|
54
|
+
schemeName: string;
|
|
55
|
+
scopes: readonly string[];
|
|
56
|
+
scheme: SecurityScheme;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* One security alternative. Several `SecurityCall`s inside one requirement are
|
|
60
|
+
* conjunctive — all must be satisfied.
|
|
61
|
+
*/
|
|
62
|
+
export type SecurityRequirement = readonly SecurityCall[];
|
|
2
63
|
/**
|
|
3
64
|
* Performs an HTTP request and returns the response.
|
|
4
65
|
*
|
|
5
66
|
* When `expectStream` is true, the implementation should return
|
|
6
67
|
* a `StreamResponse` containing the stream data, filename (from
|
|
7
68
|
* Content-Disposition header), and response headers.
|
|
69
|
+
*
|
|
70
|
+
* When `security` is present, it carries the operation's security requirements
|
|
71
|
+
* as an OR-list of AND-alternatives (spec `security` semantics): satisfying any
|
|
72
|
+
* one requirement authorizes the request. Each call carries the fully resolved
|
|
73
|
+
* scheme object. Absent `security` means the operation is public.
|
|
8
74
|
*/
|
|
9
75
|
export type Requester = <TResponse>(method: string, path: string, options: {
|
|
10
76
|
query?: Record<string, unknown>;
|
|
11
77
|
body?: unknown;
|
|
12
78
|
headers?: Record<string, string>;
|
|
13
79
|
expectStream?: true;
|
|
80
|
+
security?: readonly SecurityRequirement[];
|
|
14
81
|
}) => Promise<TResponse | StreamResponse | ErrorResponse>;
|
package/dist/types/openapi.d.ts
CHANGED
|
@@ -72,7 +72,7 @@ export type OperationObject = {
|
|
|
72
72
|
requestBody?: RequestBodyObject | ReferenceObject;
|
|
73
73
|
responses: ResponsesObject;
|
|
74
74
|
deprecated?: boolean;
|
|
75
|
-
security?:
|
|
75
|
+
security?: SecurityRequirementObject[];
|
|
76
76
|
servers?: unknown[];
|
|
77
77
|
};
|
|
78
78
|
export type PathItemObject = {
|
|
@@ -140,8 +140,9 @@ export type OAuth2FlowsObject = {
|
|
|
140
140
|
clientCredentials?: OAuth2FlowClientCredentials;
|
|
141
141
|
authorizationCode?: OAuth2FlowAuthorizationCode;
|
|
142
142
|
};
|
|
143
|
+
export type SecurityRequirementObject = Record<string, string[]>;
|
|
143
144
|
export type SecuritySchemeObject = {
|
|
144
|
-
type: 'apiKey' | 'http' | 'oauth2' | 'openIdConnect';
|
|
145
|
+
type: 'apiKey' | 'http' | 'oauth2' | 'openIdConnect' | 'mutualTLS';
|
|
145
146
|
description?: string;
|
|
146
147
|
name?: string;
|
|
147
148
|
in?: 'query' | 'header' | 'cookie';
|
|
@@ -156,7 +157,7 @@ export type ComponentsObject = {
|
|
|
156
157
|
parameters?: Record<string, ParameterObject | ReferenceObject>;
|
|
157
158
|
requestBodies?: Record<string, RequestBodyObject | ReferenceObject>;
|
|
158
159
|
headers?: Record<string, unknown>;
|
|
159
|
-
securitySchemes?: Record<string, SecuritySchemeObject>;
|
|
160
|
+
securitySchemes?: Record<string, SecuritySchemeObject | ReferenceObject>;
|
|
160
161
|
links?: Record<string, unknown>;
|
|
161
162
|
callbacks?: Record<string, unknown>;
|
|
162
163
|
examples?: Record<string, unknown>;
|
|
@@ -167,7 +168,7 @@ export type OpenAPIDocument = {
|
|
|
167
168
|
servers?: ServerObject[];
|
|
168
169
|
paths?: PathsObject;
|
|
169
170
|
components?: ComponentsObject;
|
|
170
|
-
security?:
|
|
171
|
+
security?: SecurityRequirementObject[];
|
|
171
172
|
tags?: unknown[];
|
|
172
173
|
externalDocs?: {
|
|
173
174
|
description?: string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The eight OpenAPI Operation Object HTTP methods, in canonical generation
|
|
3
|
+
* order (the order methods appear in generated clients).
|
|
4
|
+
*
|
|
5
|
+
* Single source shared by the analyzer (path-item iteration) and the
|
|
6
|
+
* validators (per-operation checks) — do not inline local copies.
|
|
7
|
+
*/
|
|
8
|
+
export declare const HTTP_METHODS: readonly ["get", "post", "put", "patch", "delete", "options", "head", "trace"];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The eight OpenAPI Operation Object HTTP methods, in canonical generation
|
|
3
|
+
* order (the order methods appear in generated clients).
|
|
4
|
+
*
|
|
5
|
+
* Single source shared by the analyzer (path-item iteration) and the
|
|
6
|
+
* validators (per-operation checks) — do not inline local copies.
|
|
7
|
+
*/
|
|
8
|
+
export const HTTP_METHODS = [
|
|
9
|
+
'get',
|
|
10
|
+
'post',
|
|
11
|
+
'put',
|
|
12
|
+
'patch',
|
|
13
|
+
'delete',
|
|
14
|
+
'options',
|
|
15
|
+
'head',
|
|
16
|
+
'trace',
|
|
17
|
+
];
|