@spec2ts/openapi 2.0.0-beta.7 → 2.0.0-beta.8
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/CHANGELOG.md +11 -0
- package/lib/core-parser.d.ts +2 -1
- package/lib/core-parser.js +7 -4
- package/lib/openapi-parser.d.ts +1 -0
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [2.0.0-beta.8](https://github.com/touchifyapp/spec2ts/compare/@spec2ts/openapi@2.0.0-beta.7...@spec2ts/openapi@2.0.0-beta.8) (2022-09-21)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **openapi:** add option to disable date parsing in querystring ([e69547f](https://github.com/touchifyapp/spec2ts/commit/e69547ffdeb87cebe18cb622eee1d46829b35ad4))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [2.0.0-beta.7](https://github.com/touchifyapp/spec2ts/compare/@spec2ts/openapi@2.0.0-beta.6...@spec2ts/openapi@2.0.0-beta.7) (2022-07-29)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @spec2ts/openapi
|
package/lib/core-parser.d.ts
CHANGED
|
@@ -18,10 +18,11 @@ export interface OApiParserContext extends ParserContext {
|
|
|
18
18
|
}
|
|
19
19
|
export declare function parsePathItem(path: string, item: PathItemObject, context: OApiParserContext, result: ParseOpenApiResult): void;
|
|
20
20
|
export declare function parseOperation(path: string, verb: string, operation: OperationObject, baseParams: ParsedParams | undefined, context: OApiParserContext, result: ParseOpenApiResult): void;
|
|
21
|
+
export declare type ParamType = "params" | "headers" | "query" | "cookie";
|
|
21
22
|
export declare function parseParameters(baseName: string, data: Array<ReferenceObject | ParameterObject>, baseParams: ParsedParams | undefined, context: OApiParserContext, result: ParseOpenApiResult): ParsedParams;
|
|
22
23
|
export declare function parseReference(ref: ParsedReference, context: ParserContext): void;
|
|
23
24
|
export declare function getContentDeclaration(name: string, content: ReferenceObject | ContentObject | undefined, context: OApiParserContext): ts.Statement | undefined;
|
|
24
|
-
export declare function getParamType(data: ParameterObject[], baseType: ts.TypeReferenceNode | undefined, context: OApiParserContext
|
|
25
|
+
export declare function getParamType(paramType: ParamType, data: ParameterObject[], baseType: ts.TypeReferenceNode | undefined, context: OApiParserContext): ts.TypeNode;
|
|
25
26
|
export declare function getSchemaFromContent(content: ContentObject): SchemaObject | ReferenceObject | undefined;
|
|
26
27
|
export declare function getResponseName(operationName: string, statusCode: string, context: OApiParserContext): string;
|
|
27
28
|
export declare function getOperationName(verb: string, path: string, operationId: string | undefined, context: OApiParserContext): string;
|
package/lib/core-parser.js
CHANGED
|
@@ -74,7 +74,7 @@ function parseParameters(baseName, data, baseParams = {}, context, result) {
|
|
|
74
74
|
if (!params.length)
|
|
75
75
|
return;
|
|
76
76
|
const name = baseName + core_parser_1.pascalCase(paramType);
|
|
77
|
-
const type = getParamType(params, baseParams[paramType], context
|
|
77
|
+
const type = getParamType(paramType, params, baseParams[paramType], context);
|
|
78
78
|
addToOpenApiResult(result, paramType, core.createTypeOrInterfaceDeclaration({
|
|
79
79
|
modifiers: [core.modifier.export],
|
|
80
80
|
name,
|
|
@@ -110,12 +110,12 @@ function getContentDeclaration(name, content, context) {
|
|
|
110
110
|
});
|
|
111
111
|
}
|
|
112
112
|
exports.getContentDeclaration = getContentDeclaration;
|
|
113
|
-
function getParamType(data, baseType, context
|
|
113
|
+
function getParamType(paramType, data, baseType, context) {
|
|
114
114
|
const required = [];
|
|
115
115
|
const props = {};
|
|
116
116
|
data.forEach(m => {
|
|
117
117
|
let name = m.name;
|
|
118
|
-
if (
|
|
118
|
+
if (paramType === "headers" && context.options.lowerHeaders) {
|
|
119
119
|
name = name.toLowerCase();
|
|
120
120
|
}
|
|
121
121
|
props[name] = m.schema || {};
|
|
@@ -123,7 +123,10 @@ function getParamType(data, baseType, context, isHeader) {
|
|
|
123
123
|
required.push(name);
|
|
124
124
|
}
|
|
125
125
|
});
|
|
126
|
-
const
|
|
126
|
+
const ctx = paramType === "query" && typeof context.options.enableDateForQueryParams !== "undefined"
|
|
127
|
+
? { ...context, options: { ...context.options, enableDate: context.options.enableDateForQueryParams } }
|
|
128
|
+
: context;
|
|
129
|
+
const type = core_parser_1.getTypeFromProperties(props, required, false, ctx);
|
|
127
130
|
if (baseType) {
|
|
128
131
|
return ts.factory.createIntersectionTypeNode([baseType, type]);
|
|
129
132
|
}
|
package/lib/openapi-parser.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { ParseOpenApiResult } from "./core-parser";
|
|
|
4
4
|
export { ParseOpenApiResult };
|
|
5
5
|
export interface ParseOpenApiOptions extends ParserOptions {
|
|
6
6
|
lowerHeaders?: boolean;
|
|
7
|
+
enableDateForQueryParams?: boolean | "strict" | "lax";
|
|
7
8
|
}
|
|
8
9
|
export declare function parseOpenApiFile(file: string, options?: ParseOpenApiOptions): Promise<ParseOpenApiResult>;
|
|
9
10
|
export declare function parseOpenApi(spec: OpenAPIObject, options?: ParseOpenApiOptions): Promise<ParseOpenApiResult>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spec2ts/openapi",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.8",
|
|
4
4
|
"description": "Utility to convert OpenAPI v3 specifications to Typescript using TypeScript native compiler",
|
|
5
5
|
"author": "Touchify <dev@touchify.co>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -35,19 +35,19 @@
|
|
|
35
35
|
"lint:ts": "eslint \"*.ts\" \"{bin,cli,lib}/**/*.ts\"",
|
|
36
36
|
"lint:fix": "npm run lint -- -- --fix",
|
|
37
37
|
"clean": "npm run clean:ts",
|
|
38
|
-
"clean:ts": "
|
|
38
|
+
"clean:ts": "del *.{js,d.ts} {bin,cli,lib}/**/*.{js,d.ts}",
|
|
39
39
|
"prepublishOnly": "npm test && npm run build"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@spec2ts/core": "^2.0.0-beta.
|
|
43
|
-
"@spec2ts/jsonschema": "^2.0.0-beta.
|
|
42
|
+
"@spec2ts/core": "^2.0.0-beta.3",
|
|
43
|
+
"@spec2ts/jsonschema": "^2.0.0-beta.8",
|
|
44
44
|
"openapi3-ts": "^1.3.0",
|
|
45
45
|
"yargs": "^15.3.1"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
+
"del-cli": "^5.0.0",
|
|
48
49
|
"eslint": "^7.11.0",
|
|
49
50
|
"jest": "^26.5.3",
|
|
50
|
-
"rimraf": "^3.0.2",
|
|
51
51
|
"typescript": "^4.0.0"
|
|
52
52
|
},
|
|
53
53
|
"keywords": [
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"spec2ts",
|
|
66
66
|
"share"
|
|
67
67
|
],
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "8a84aeb712db730d94b5c0dc3814f0fbd3bf348e"
|
|
69
69
|
}
|