@sapporta/rest-open-api 3.52.1 → 3.52.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/CHANGELOG.md +6 -0
- package/README.md +76 -9
- package/index.cjs.d.ts +1 -0
- package/index.cjs.default.js +1 -0
- package/index.cjs.js +673 -0
- package/index.cjs.mjs +2 -0
- package/index.esm.js +668 -0
- package/package.json +15 -5
- package/src/index.d.ts +2 -0
- package/src/lib/contract-traversal.d.ts +14 -0
- package/src/lib/parsers/body.d.ts +14 -0
- package/src/lib/parsers/headers.d.ts +14 -0
- package/src/lib/parsers/path-params.d.ts +20 -0
- package/src/lib/parsers/query-params.d.ts +15 -0
- package/src/lib/parsers/test-helpers.d.ts +4 -0
- package/src/lib/parsers/utils.d.ts +11 -0
- package/src/lib/ts-rest-open-api.d.ts +46 -0
- package/src/lib/types.d.ts +83 -0
- package/src/lib/utils.d.ts +5 -0
- package/.babelrc +0 -10
- package/.eslintrc.json +0 -21
- package/jest.config.ts +0 -16
- package/project.json +0 -51
- package/src/index.ts +0 -6
- package/src/lib/contract-traversal.ts +0 -217
- package/src/lib/parsers/body.ts +0 -71
- package/src/lib/parsers/headers.ts +0 -163
- package/src/lib/parsers/path-params.spec.ts +0 -235
- package/src/lib/parsers/path-params.ts +0 -140
- package/src/lib/parsers/query-params.spec.ts +0 -129
- package/src/lib/parsers/query-params.ts +0 -89
- package/src/lib/parsers/test-helpers.ts +0 -26
- package/src/lib/parsers/utils.spec.ts +0 -117
- package/src/lib/parsers/utils.ts +0 -82
- package/src/lib/ts-rest-open-api.ts +0 -245
- package/src/lib/types.ts +0 -109
- package/src/lib/utils.ts +0 -92
- package/tsconfig.json +0 -22
- package/tsconfig.lib.json +0 -10
- package/tsconfig.spec.json +0 -9
- package/typedoc.json +0 -5
- /package/src/lib/parsers/{index.ts → index.d.ts} +0 -0
package/src/lib/utils.ts
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { SchemaObject, MediaTypeObject, ReferenceObject } from 'openapi3-ts';
|
|
2
|
-
|
|
3
|
-
export const convertSchemaObjectToMediaTypeObject = (
|
|
4
|
-
input: SchemaObject,
|
|
5
|
-
): MediaTypeObject => {
|
|
6
|
-
const { mediaExamples: examples, ...schema } = input;
|
|
7
|
-
|
|
8
|
-
return {
|
|
9
|
-
schema,
|
|
10
|
-
...(examples && { examples }),
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export const extractReferenceSchemas = (
|
|
15
|
-
schema: SchemaObject,
|
|
16
|
-
referenceSchemas: { [id: string]: SchemaObject },
|
|
17
|
-
): SchemaObject => {
|
|
18
|
-
if (schema.allOf) {
|
|
19
|
-
schema.allOf = schema.allOf?.map((subSchema) =>
|
|
20
|
-
extractReferenceSchemas(subSchema, referenceSchemas),
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (schema.anyOf) {
|
|
25
|
-
schema.anyOf = schema.anyOf?.map((subSchema) =>
|
|
26
|
-
extractReferenceSchemas(subSchema, referenceSchemas),
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (schema.oneOf) {
|
|
31
|
-
schema.oneOf = schema.oneOf?.map((subSchema) =>
|
|
32
|
-
extractReferenceSchemas(subSchema, referenceSchemas),
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (schema.not) {
|
|
37
|
-
schema.not = extractReferenceSchemas(schema.not, referenceSchemas);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (schema.items) {
|
|
41
|
-
schema.items = extractReferenceSchemas(schema.items, referenceSchemas);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (schema.properties) {
|
|
45
|
-
schema.properties = Object.entries(schema.properties).reduce<{
|
|
46
|
-
[p: string]: SchemaObject | ReferenceObject;
|
|
47
|
-
}>((prev, [propertyName, schema]) => {
|
|
48
|
-
prev[propertyName] = extractReferenceSchemas(schema, referenceSchemas);
|
|
49
|
-
return prev;
|
|
50
|
-
}, {});
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (schema.additionalProperties) {
|
|
54
|
-
schema.additionalProperties =
|
|
55
|
-
typeof schema.additionalProperties != 'boolean'
|
|
56
|
-
? extractReferenceSchemas(schema.additionalProperties, referenceSchemas)
|
|
57
|
-
: schema.additionalProperties;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (schema.title) {
|
|
61
|
-
const nullable = schema.nullable;
|
|
62
|
-
schema.nullable = undefined;
|
|
63
|
-
if (schema.title in referenceSchemas) {
|
|
64
|
-
if (
|
|
65
|
-
JSON.stringify(referenceSchemas[schema.title]) !==
|
|
66
|
-
JSON.stringify(schema)
|
|
67
|
-
) {
|
|
68
|
-
throw new Error(
|
|
69
|
-
`Schema title '${schema.title}' already exists with a different schema`,
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
} else {
|
|
73
|
-
referenceSchemas[schema.title] = schema;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (nullable) {
|
|
77
|
-
schema = {
|
|
78
|
-
nullable: true,
|
|
79
|
-
allOf: [
|
|
80
|
-
{
|
|
81
|
-
$ref: `#/components/schemas/${schema.title}`,
|
|
82
|
-
},
|
|
83
|
-
],
|
|
84
|
-
};
|
|
85
|
-
} else {
|
|
86
|
-
schema = {
|
|
87
|
-
$ref: `#/components/schemas/${schema.title}`,
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
return schema;
|
|
92
|
-
};
|
package/tsconfig.json
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../../tsconfig.base.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"module": "commonjs",
|
|
5
|
-
"forceConsistentCasingInFileNames": true,
|
|
6
|
-
"strict": true,
|
|
7
|
-
"noImplicitOverride": true,
|
|
8
|
-
"noPropertyAccessFromIndexSignature": true,
|
|
9
|
-
"noImplicitReturns": true,
|
|
10
|
-
"noFallthroughCasesInSwitch": true
|
|
11
|
-
},
|
|
12
|
-
"files": [],
|
|
13
|
-
"include": [],
|
|
14
|
-
"references": [
|
|
15
|
-
{
|
|
16
|
-
"path": "./tsconfig.lib.json"
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
"path": "./tsconfig.spec.json"
|
|
20
|
-
}
|
|
21
|
-
]
|
|
22
|
-
}
|
package/tsconfig.lib.json
DELETED
package/tsconfig.spec.json
DELETED
package/typedoc.json
DELETED
|
File without changes
|