@tsed/schema 8.0.1 → 8.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/package.json +11 -10
- package/src/components/async-api/channelsMapper.ts +81 -0
- package/src/components/async-api/generate.ts +24 -0
- package/src/components/async-api/messageMapper.ts +62 -0
- package/src/components/async-api/payloadMapper.ts +61 -0
- package/src/components/async-api/responseMapper.ts +70 -0
- package/src/components/default/anyMapper.spec.ts +7 -0
- package/src/components/default/anyMapper.ts +33 -0
- package/src/components/default/classMapper.ts +55 -0
- package/src/components/default/discriminatorMappingMapper.ts +36 -0
- package/src/components/default/enumsMapper.spec.ts +64 -0
- package/src/components/default/enumsMapper.ts +17 -0
- package/src/components/default/genericsMapper.ts +70 -0
- package/src/components/default/inheritedClassMapper.ts +24 -0
- package/src/components/default/itemMapper.ts +8 -0
- package/src/components/default/lazyRefMapper.ts +21 -0
- package/src/components/default/mapMapper.ts +25 -0
- package/src/components/default/nullableMapper.ts +55 -0
- package/src/components/default/objectMapper.ts +36 -0
- package/src/components/default/ofMapper.ts +16 -0
- package/src/components/default/propertiesMapper.ts +25 -0
- package/src/components/default/requiredMapper.ts +69 -0
- package/src/components/default/schemaMapper.ts +151 -0
- package/src/components/index.ts +36 -0
- package/src/components/open-spec/discriminatorMappingMapper.ts +7 -0
- package/src/components/open-spec/enumsMapper.ts +20 -0
- package/src/components/open-spec/generate.ts +29 -0
- package/src/components/open-spec/nullableMapper.ts +51 -0
- package/src/components/open-spec/operationInFilesMapper.ts +32 -0
- package/src/components/open-spec/operationInParameterMapper.ts +56 -0
- package/src/components/open-spec/operationInParametersMapper.ts +9 -0
- package/src/components/open-spec/operationInQueryMapper.ts +74 -0
- package/src/components/open-spec/operationMapper.ts +65 -0
- package/src/components/open-spec/operationMediaMapper.ts +11 -0
- package/src/components/open-spec/operationRequestBodyMapper.ts +82 -0
- package/src/components/open-spec/operationResponseMapper.ts +26 -0
- package/src/components/open-spec/pathsMapper.ts +132 -0
- package/src/constants/OperationVerbs.ts +29 -0
- package/src/constants/httpStatusMessages.ts +21 -0
- package/src/constants/jsonSchemaProperties.ts +17 -0
- package/src/decorators/class/children.ts +22 -0
- package/src/decorators/class/discriminatorValue.ts +53 -0
- package/src/decorators/collections/collectionContains.ts +25 -0
- package/src/decorators/collections/collectionOf.spec.ts +327 -0
- package/src/decorators/collections/collectionOf.ts +182 -0
- package/src/decorators/collections/maxItems.spec.ts +40 -0
- package/src/decorators/collections/maxItems.ts +59 -0
- package/src/decorators/collections/maxProperties.spec.ts +109 -0
- package/src/decorators/collections/maxProperties.ts +82 -0
- package/src/decorators/collections/minItems.spec.ts +40 -0
- package/src/decorators/collections/minItems.ts +63 -0
- package/src/decorators/collections/minProperties.spec.ts +109 -0
- package/src/decorators/collections/minProperties.ts +81 -0
- package/src/decorators/collections/uniqueItems.spec.ts +28 -0
- package/src/decorators/collections/uniqueItems.ts +59 -0
- package/src/decorators/common/__snapshots__/groups.spec.ts.snap +321 -0
- package/src/decorators/common/additionalProperties.spec.ts +133 -0
- package/src/decorators/common/additionalProperties.ts +17 -0
- package/src/decorators/common/allOf.spec.ts +276 -0
- package/src/decorators/common/allOf.ts +19 -0
- package/src/decorators/common/allow.spec.ts +130 -0
- package/src/decorators/common/allow.ts +50 -0
- package/src/decorators/common/any.spec.ts +109 -0
- package/src/decorators/common/any.ts +45 -0
- package/src/decorators/common/anyOf.spec.ts +270 -0
- package/src/decorators/common/anyOf.ts +23 -0
- package/src/decorators/common/const.spec.ts +98 -0
- package/src/decorators/common/const.ts +68 -0
- package/src/decorators/common/customKey.spec.ts +105 -0
- package/src/decorators/common/customKey.ts +39 -0
- package/src/decorators/common/default.spec.ts +25 -0
- package/src/decorators/common/default.ts +47 -0
- package/src/decorators/common/defaultMsg.spec.ts +22 -0
- package/src/decorators/common/defaultMsg.ts +38 -0
- package/src/decorators/common/description.spec.ts +166 -0
- package/src/decorators/common/description.ts +77 -0
- package/src/decorators/common/discriminatorKey.ts +14 -0
- package/src/decorators/common/enum.spec.ts +305 -0
- package/src/decorators/common/enum.ts +111 -0
- package/src/decorators/common/errorMsg.spec.ts +57 -0
- package/src/decorators/common/errorMsg.ts +14 -0
- package/src/decorators/common/example.spec.ts +93 -0
- package/src/decorators/common/example.ts +18 -0
- package/src/decorators/common/examples.spec.ts +101 -0
- package/src/decorators/common/examples.ts +20 -0
- package/src/decorators/common/exclusiveMaximum.spec.ts +47 -0
- package/src/decorators/common/exclusiveMaximum.ts +75 -0
- package/src/decorators/common/exclusiveMinimum.spec.ts +47 -0
- package/src/decorators/common/exclusiveMinimum.ts +75 -0
- package/src/decorators/common/format.spec.ts +149 -0
- package/src/decorators/common/format.ts +486 -0
- package/src/decorators/common/forwardGroups.spec.ts +270 -0
- package/src/decorators/common/forwardGroups.ts +16 -0
- package/src/decorators/common/groups.spec.ts +968 -0
- package/src/decorators/common/groups.ts +66 -0
- package/src/decorators/common/hidden.spec.ts +52 -0
- package/src/decorators/common/hidden.ts +36 -0
- package/src/decorators/common/ignore.spec.ts +88 -0
- package/src/decorators/common/ignore.ts +66 -0
- package/src/decorators/common/integer.spec.ts +110 -0
- package/src/decorators/common/integer.ts +69 -0
- package/src/decorators/common/jsonEntityFn.spec.ts +16 -0
- package/src/decorators/common/jsonEntityFn.ts +33 -0
- package/src/decorators/common/maxLength.spec.ts +61 -0
- package/src/decorators/common/maxLength.ts +88 -0
- package/src/decorators/common/maximum.spec.ts +73 -0
- package/src/decorators/common/maximum.ts +146 -0
- package/src/decorators/common/minLength.spec.ts +186 -0
- package/src/decorators/common/minLength.ts +89 -0
- package/src/decorators/common/minimum.spec.ts +74 -0
- package/src/decorators/common/minimum.ts +145 -0
- package/src/decorators/common/multipleOf.spec.ts +33 -0
- package/src/decorators/common/multipleOf.ts +80 -0
- package/src/decorators/common/name.spec.ts +56 -0
- package/src/decorators/common/name.ts +50 -0
- package/src/decorators/common/nullable.spec.ts +818 -0
- package/src/decorators/common/nullable.ts +32 -0
- package/src/decorators/common/oneOf.spec.ts +301 -0
- package/src/decorators/common/oneOf.ts +24 -0
- package/src/decorators/common/optional.spec.ts +43 -0
- package/src/decorators/common/optional.ts +26 -0
- package/src/decorators/common/pattern.spec.ts +27 -0
- package/src/decorators/common/pattern.ts +102 -0
- package/src/decorators/common/property.ts +24 -0
- package/src/decorators/common/readOnly.spec.ts +135 -0
- package/src/decorators/common/readOnly.ts +17 -0
- package/src/decorators/common/recordOf.spec.ts +41 -0
- package/src/decorators/common/recordOf.ts +59 -0
- package/src/decorators/common/required.spec.ts +188 -0
- package/src/decorators/common/required.ts +50 -0
- package/src/decorators/common/requiredGroups.spec.ts +127 -0
- package/src/decorators/common/requiredGroups.ts +23 -0
- package/src/decorators/common/schema.spec.ts +23 -0
- package/src/decorators/common/schema.ts +64 -0
- package/src/decorators/common/title.spec.ts +20 -0
- package/src/decorators/common/title.ts +45 -0
- package/src/decorators/common/typeError.spec.ts +22 -0
- package/src/decorators/common/typeError.ts +15 -0
- package/src/decorators/common/writeOnly.spec.ts +105 -0
- package/src/decorators/common/writeOnly.ts +17 -0
- package/src/decorators/config/jsonEntityComponent.ts +16 -0
- package/src/decorators/generics/genericOf.spec.ts +246 -0
- package/src/decorators/generics/genericOf.ts +112 -0
- package/src/decorators/generics/generics.ts +22 -0
- package/src/decorators/operations/acceptMime.spec.ts +39 -0
- package/src/decorators/operations/acceptMime.ts +25 -0
- package/src/decorators/operations/consumes.spec.ts +89 -0
- package/src/decorators/operations/consumes.ts +37 -0
- package/src/decorators/operations/contentType.spec.ts +40 -0
- package/src/decorators/operations/contentType.ts +24 -0
- package/src/decorators/operations/deprecated.spec.ts +223 -0
- package/src/decorators/operations/deprecated.ts +49 -0
- package/src/decorators/operations/header.spec.ts +214 -0
- package/src/decorators/operations/header.ts +62 -0
- package/src/decorators/operations/in.spec.ts +321 -0
- package/src/decorators/operations/in.ts +141 -0
- package/src/decorators/operations/inFile.spec.ts +209 -0
- package/src/decorators/operations/inFile.ts +55 -0
- package/src/decorators/operations/location.spec.ts +51 -0
- package/src/decorators/operations/location.ts +26 -0
- package/src/decorators/operations/operation.ts +119 -0
- package/src/decorators/operations/operationId.spec.ts +43 -0
- package/src/decorators/operations/operationId.ts +22 -0
- package/src/decorators/operations/operationPath.spec.ts +42 -0
- package/src/decorators/operations/operationPath.ts +33 -0
- package/src/decorators/operations/partial.spec.ts +249 -0
- package/src/decorators/operations/partial.ts +14 -0
- package/src/decorators/operations/path.spec.ts +47 -0
- package/src/decorators/operations/path.ts +27 -0
- package/src/decorators/operations/produces.spec.ts +89 -0
- package/src/decorators/operations/produces.ts +44 -0
- package/src/decorators/operations/publish.spec.ts +26 -0
- package/src/decorators/operations/publish.ts +6 -0
- package/src/decorators/operations/redirect.spec.ts +146 -0
- package/src/decorators/operations/redirect.ts +82 -0
- package/src/decorators/operations/returns.spec.ts +1393 -0
- package/src/decorators/operations/returns.ts +662 -0
- package/src/decorators/operations/route.spec.ts +211 -0
- package/src/decorators/operations/route.ts +154 -0
- package/src/decorators/operations/security.spec.ts +162 -0
- package/src/decorators/operations/security.ts +83 -0
- package/src/decorators/operations/status.spec.ts +582 -0
- package/src/decorators/operations/status.ts +130 -0
- package/src/decorators/operations/subscribe.spec.ts +32 -0
- package/src/decorators/operations/subscribe.ts +6 -0
- package/src/decorators/operations/summary.spec.ts +45 -0
- package/src/decorators/operations/summary.ts +32 -0
- package/src/decorators/operations/tags.spec.ts +113 -0
- package/src/decorators/operations/tags.ts +53 -0
- package/src/decorators/operations/view.spec.ts +16 -0
- package/src/decorators/operations/view.ts +27 -0
- package/src/domain/DecoratorContext.ts +116 -0
- package/src/domain/JsonAliasMap.ts +19 -0
- package/src/domain/JsonClassStore.ts +35 -0
- package/src/domain/JsonDiscriminator.spec.ts +65 -0
- package/src/domain/JsonDiscriminator.ts +52 -0
- package/src/domain/JsonEntityStore.spec.ts +277 -0
- package/src/domain/JsonEntityStore.ts +284 -0
- package/src/domain/JsonFormatTypes.ts +17 -0
- package/src/domain/JsonLazyRef.ts +21 -0
- package/src/domain/JsonMap.spec.ts +15 -0
- package/src/domain/JsonMap.ts +33 -0
- package/src/domain/JsonMedia.ts +24 -0
- package/src/domain/JsonMethodStore.spec.ts +301 -0
- package/src/domain/JsonMethodStore.ts +212 -0
- package/src/domain/JsonOperation.spec.ts +126 -0
- package/src/domain/JsonOperation.ts +219 -0
- package/src/domain/JsonOperationPathsMap.ts +16 -0
- package/src/domain/JsonOperationRoute.spec.ts +109 -0
- package/src/domain/JsonOperationRoute.ts +75 -0
- package/src/domain/JsonParameter.ts +70 -0
- package/src/domain/JsonParameterStore.spec.ts +212 -0
- package/src/domain/JsonParameterStore.ts +138 -0
- package/src/domain/JsonParameterTypes.spec.ts +12 -0
- package/src/domain/JsonParameterTypes.ts +20 -0
- package/src/domain/JsonPropertyStore.spec.ts +177 -0
- package/src/domain/JsonPropertyStore.ts +92 -0
- package/src/domain/JsonRequestBody.ts +47 -0
- package/src/domain/JsonResponse.spec.ts +33 -0
- package/src/domain/JsonResponse.ts +64 -0
- package/src/domain/JsonSchema.spec.ts +1470 -0
- package/src/domain/JsonSchema.ts +1049 -0
- package/src/domain/SpecTypes.ts +6 -0
- package/src/hooks/alterIgnore.ts +25 -0
- package/src/hooks/alterOneOf.ts +67 -0
- package/src/hooks/alterRequiredGroups.ts +12 -0
- package/src/index.ts +185 -0
- package/src/interfaces/IgnoreCallback.ts +5 -0
- package/src/interfaces/JsonHookContext.ts +18 -0
- package/src/interfaces/JsonOpenSpec.ts +7 -0
- package/src/interfaces/JsonSchemaOptions.ts +35 -0
- package/src/registries/JsonSchemaMapperContainer.ts +52 -0
- package/src/registries/enumRegistries.ts +3 -0
- package/src/utils/__snapshots__/generateSpec.spec.ts.snap +109 -0
- package/src/utils/buildPath.ts +8 -0
- package/src/utils/concatParameters.ts +12 -0
- package/src/utils/concatPath.spec.ts +23 -0
- package/src/utils/concatPath.ts +24 -0
- package/src/utils/defineStatusModel.ts +11 -0
- package/src/utils/from.spec.ts +243 -0
- package/src/utils/from.ts +281 -0
- package/src/utils/generateSpec.spec.ts +1262 -0
- package/src/utils/generateSpec.ts +54 -0
- package/src/utils/generics.ts +83 -0
- package/src/utils/getComputedType.spec.ts +45 -0
- package/src/utils/getComputedType.ts +39 -0
- package/src/utils/getInheritedStores.spec.ts +47 -0
- package/src/utils/getInheritedStores.ts +23 -0
- package/src/utils/getJsonEntityStore.ts +36 -0
- package/src/utils/getJsonPathParameters.spec.ts +126 -0
- package/src/utils/getJsonPathParameters.ts +97 -0
- package/src/utils/getJsonSchema.spec.ts +695 -0
- package/src/utils/getJsonSchema.ts +69 -0
- package/src/utils/getJsonType.spec.ts +28 -0
- package/src/utils/getJsonType.ts +46 -0
- package/src/utils/getOperationsRoutes.spec.ts +284 -0
- package/src/utils/getOperationsRoutes.ts +56 -0
- package/src/utils/getOperationsStore.spec.ts +47 -0
- package/src/utils/getOperationsStores.ts +37 -0
- package/src/utils/getPropertiesStores.spec.ts +138 -0
- package/src/utils/getPropertiesStores.ts +66 -0
- package/src/utils/getSpec.spec.ts +610 -0
- package/src/utils/getSpec.ts +117 -0
- package/src/utils/getSpecType.spec.ts +16 -0
- package/src/utils/getSpecType.ts +19 -0
- package/src/utils/isSuccessStatus.spec.ts +22 -0
- package/src/utils/isSuccessStatus.ts +2 -0
- package/src/utils/mapHeaders.spec.ts +57 -0
- package/src/utils/mapHeaders.ts +33 -0
- package/src/utils/mapOpenSpec.ts +44 -0
- package/src/utils/mapOpenSpec2.ts +50 -0
- package/src/utils/mapOpenSpec3.ts +25 -0
- package/src/utils/mapOpenSpecInfo.ts +19 -0
- package/src/utils/mapOperationOptions.ts +34 -0
- package/src/utils/matchGroups.spec.ts +85 -0
- package/src/utils/matchGroups.ts +64 -0
- package/src/utils/mergeSpec.spec.ts +533 -0
- package/src/utils/mergeSpec.ts +54 -0
- package/src/utils/operationIdFormatter.spec.ts +11 -0
- package/src/utils/operationIdFormatter.ts +49 -0
- package/src/utils/ref.ts +65 -0
- package/src/utils/removeHiddenOperation.ts +5 -0
- package/src/utils/serializeEnumValues.ts +27 -0
- package/src/utils/somethingOf.ts +11 -0
- package/src/utils/toJsonMapCollection.spec.ts +18 -0
- package/src/utils/toJsonMapCollection.ts +12 -0
- package/src/utils/toJsonRegex.ts +7 -0
- package/src/utils/transformToOS2.spec.ts +177 -0
- package/src/utils/transformToOS2.ts +607 -0
- package/src/utils/withErrorMsg.spec.ts +16 -0
- package/src/utils/withErrorMsg.ts +56 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {isObject, uniq} from "@tsed/core";
|
|
2
|
+
|
|
3
|
+
export const serializeEnum = (enumValue: any) => {
|
|
4
|
+
if (isObject(enumValue) && enumValue !== null) {
|
|
5
|
+
return Object.entries(enumValue).reduce((acc: any, [key, value]: any) => {
|
|
6
|
+
if (isNaN(+key)) {
|
|
7
|
+
return acc.concat(value);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return acc;
|
|
11
|
+
}, []);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return enumValue;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export function serializeEnumValues(enumValues: any[]) {
|
|
18
|
+
const values = enumValues.reduce((acc, value) => acc.concat(serializeEnum(value)), []);
|
|
19
|
+
|
|
20
|
+
const getValue = (value: any) => {
|
|
21
|
+
return value === null ? "null" : typeof value;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const types = values.reduce((set: Set<any>, value: any) => set.add(getValue(value)), new Set());
|
|
25
|
+
|
|
26
|
+
return {values: uniq(values), types};
|
|
27
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {JsonMap} from "../domain/JsonMap.js";
|
|
2
|
+
import {toJsonMapCollection} from "./toJsonMapCollection.js";
|
|
3
|
+
|
|
4
|
+
describe("toJsonMapCollection", () => {
|
|
5
|
+
it("should transform object to JsonMapCollection", () => {
|
|
6
|
+
const result = toJsonMapCollection({
|
|
7
|
+
test: {
|
|
8
|
+
schema: "schema"
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
expect(result).toEqual(
|
|
13
|
+
new JsonMap({
|
|
14
|
+
test: new JsonMap({schema: "schema"})
|
|
15
|
+
})
|
|
16
|
+
);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {JsonMap} from "../domain/JsonMap.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @ignore
|
|
5
|
+
*/
|
|
6
|
+
export function toJsonMapCollection(content: {[key: string]: any}, klass = JsonMap) {
|
|
7
|
+
return Object.entries(content).reduce((content, [key, value]) => {
|
|
8
|
+
content.set(key, new klass(value));
|
|
9
|
+
|
|
10
|
+
return content;
|
|
11
|
+
}, new JsonMap<any>());
|
|
12
|
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import commonParamsOS2 from "./__mock__/common_params/os2.spec.json";
|
|
2
|
+
import commonParamsOS3 from "./__mock__/common_params/os3.spec.json";
|
|
3
|
+
import deprecatedOS2 from "./__mock__/deprecated/os2.spec.json";
|
|
4
|
+
import deprecatedOS3 from "./__mock__/deprecated/os3.spec.json";
|
|
5
|
+
import formParamOS2 from "./__mock__/form_param/os2.spec.json";
|
|
6
|
+
import formParamOS3 from "./__mock__/form_param/os3.spec.json";
|
|
7
|
+
import minimalOS2 from "./__mock__/minimal/os2.spec.json";
|
|
8
|
+
import minimalOS3 from "./__mock__/minimal/os3.spec.json";
|
|
9
|
+
import multipleRefOS2 from "./__mock__/multiple_ref/os2.spec.json";
|
|
10
|
+
import multipleRefOS3 from "./__mock__/multiple_ref/os3.spec.json";
|
|
11
|
+
import nestedOneOfOS2 from "./__mock__/nested_oneof/os2.spec.json";
|
|
12
|
+
import nestedOneOfOS3 from "./__mock__/nested_oneof/os3.spec.json";
|
|
13
|
+
import nullableOS2 from "./__mock__/nullable/os2.spec.json";
|
|
14
|
+
import nullableOS3 from "./__mock__/nullable/os3.spec.json";
|
|
15
|
+
import paramSchemaRefOS2 from "./__mock__/param_schema_ref/os2.spec.json";
|
|
16
|
+
import paramSchemaRefOS3 from "./__mock__/param_schema_ref/os3.spec.json";
|
|
17
|
+
import petstoreOS2 from "./__mock__/petstore/os2.spec.json";
|
|
18
|
+
import petstoreOS3 from "./__mock__/petstore/os3.spec.json";
|
|
19
|
+
import producesOS2 from "./__mock__/produces/os2.spec.json";
|
|
20
|
+
import producesOS3 from "./__mock__/produces/os3.spec.json";
|
|
21
|
+
import requestResponseRefOS2 from "./__mock__/request_response_ref/os2.spec.json";
|
|
22
|
+
import requestResponseRefOS3 from "./__mock__/request_response_ref/os3.spec.json";
|
|
23
|
+
import serversOS2 from "./__mock__/servers/os2.spec.json";
|
|
24
|
+
import serversOS3 from "./__mock__/servers/os3.spec.json";
|
|
25
|
+
import slashRefOS2 from "./__mock__/slash_ref/os2.spec.json";
|
|
26
|
+
import slashRefOS3 from "./__mock__/slash_ref/os3.spec.json";
|
|
27
|
+
import {transformSecurity, transformToOS2} from "./transformToOS2.js";
|
|
28
|
+
|
|
29
|
+
describe("transform", () => {
|
|
30
|
+
describe("transformSecurity()", () => {
|
|
31
|
+
it("should transform security definition", () => {
|
|
32
|
+
const result = transformSecurity({
|
|
33
|
+
httpBasic: {
|
|
34
|
+
type: "http",
|
|
35
|
+
scheme: "basic"
|
|
36
|
+
},
|
|
37
|
+
httpScheme: {
|
|
38
|
+
type: "http",
|
|
39
|
+
scheme: "bearer"
|
|
40
|
+
},
|
|
41
|
+
httpUnknown: {
|
|
42
|
+
type: "http",
|
|
43
|
+
scheme: "other"
|
|
44
|
+
},
|
|
45
|
+
oauth2_accessCode: {
|
|
46
|
+
flows: {
|
|
47
|
+
authorizationCode: {
|
|
48
|
+
authorizationUrl: "http://petstore.swagger.wordnik.com/api/oauth/requestToken",
|
|
49
|
+
scopes: {
|
|
50
|
+
"read:pets": "Read your pets",
|
|
51
|
+
"write:pets": "Modify pets in your account"
|
|
52
|
+
},
|
|
53
|
+
tokenUrl: "http://petstore.swagger.wordnik.com/api/oauth/token"
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
type: "oauth2"
|
|
57
|
+
},
|
|
58
|
+
oauth2_implicit: {
|
|
59
|
+
flows: {
|
|
60
|
+
implicit: {
|
|
61
|
+
authorizationUrl: "http://petstore.swagger.wordnik.com/api/oauth/dialog",
|
|
62
|
+
scopes: {
|
|
63
|
+
"read:pets": "Read your pets",
|
|
64
|
+
"write:pets": "Modify pets in your account"
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
type: "oauth2"
|
|
69
|
+
},
|
|
70
|
+
oauth2_credential: {
|
|
71
|
+
flows: {
|
|
72
|
+
clientCredentials: {
|
|
73
|
+
authorizationUrl: "http://petstore.swagger.wordnik.com/api/oauth/dialog",
|
|
74
|
+
scopes: {
|
|
75
|
+
"read:pets": "Read your pets",
|
|
76
|
+
"write:pets": "Modify pets in your account"
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
type: "oauth2"
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
expect(result).toEqual({
|
|
85
|
+
httpBasic: {
|
|
86
|
+
type: "basic"
|
|
87
|
+
},
|
|
88
|
+
httpScheme: {
|
|
89
|
+
in: "header",
|
|
90
|
+
name: "Authorization",
|
|
91
|
+
type: "apiKey"
|
|
92
|
+
},
|
|
93
|
+
oauth2_accessCode: {
|
|
94
|
+
authorizationUrl: "http://petstore.swagger.wordnik.com/api/oauth/requestToken",
|
|
95
|
+
flow: "accessCode",
|
|
96
|
+
scopes: {
|
|
97
|
+
"read:pets": "Read your pets",
|
|
98
|
+
"write:pets": "Modify pets in your account"
|
|
99
|
+
},
|
|
100
|
+
tokenUrl: "http://petstore.swagger.wordnik.com/api/oauth/token",
|
|
101
|
+
type: "oauth2"
|
|
102
|
+
},
|
|
103
|
+
oauth2_credential: {
|
|
104
|
+
authorizationUrl: "http://petstore.swagger.wordnik.com/api/oauth/dialog",
|
|
105
|
+
flow: "application",
|
|
106
|
+
scopes: {
|
|
107
|
+
"read:pets": "Read your pets",
|
|
108
|
+
"write:pets": "Modify pets in your account"
|
|
109
|
+
},
|
|
110
|
+
type: "oauth2"
|
|
111
|
+
},
|
|
112
|
+
oauth2_implicit: {
|
|
113
|
+
authorizationUrl: "http://petstore.swagger.wordnik.com/api/oauth/dialog",
|
|
114
|
+
flow: "implicit",
|
|
115
|
+
scopes: {
|
|
116
|
+
"read:pets": "Read your pets",
|
|
117
|
+
"write:pets": "Modify pets in your account"
|
|
118
|
+
},
|
|
119
|
+
type: "oauth2"
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
describe("transformToOS2()", () => {
|
|
125
|
+
it("should transform OS3 spec to OS2 (scenario 1 - common_params)", () => {
|
|
126
|
+
expect(transformToOS2(commonParamsOS3 as any)).toEqual(commonParamsOS2);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it("should transform OS3 spec to OS2 (scenario 2 - deprecated)", () => {
|
|
130
|
+
expect(transformToOS2(deprecatedOS3 as any)).toEqual(deprecatedOS2);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it("should transform OS3 spec to OS2 (scenario 3 - minimal)", () => {
|
|
134
|
+
expect(transformToOS2(formParamOS3 as any)).toEqual(formParamOS2);
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it("should transform OS3 spec to OS2 (scenario 5 - minimal)", () => {
|
|
138
|
+
expect(transformToOS2(minimalOS3 as any)).toEqual(minimalOS2);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it("should transform OS3 spec to OS2 (scenario 6 - multiple_ref)", () => {
|
|
142
|
+
expect(transformToOS2(multipleRefOS3 as any)).toEqual(multipleRefOS2);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it("should transform OS3 spec to OS2 (scenario 7 - nested_oneof)", () => {
|
|
146
|
+
expect(transformToOS2(nestedOneOfOS3 as any)).toEqual(nestedOneOfOS2);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it("should transform OS3 spec to OS2 (scenario 8 - nullable)", () => {
|
|
150
|
+
expect(transformToOS2(nullableOS3 as any)).toEqual(nullableOS2);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it("should transform OS3 spec to OS2 (scenario 9 - param_schema_ref)", () => {
|
|
154
|
+
expect(transformToOS2(paramSchemaRefOS3 as any)).toEqual(paramSchemaRefOS2);
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it("should transform OS3 spec to OS2 (scenario 10 - petstore)", () => {
|
|
158
|
+
expect(transformToOS2(petstoreOS3 as any)).toEqual(petstoreOS2);
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it("should transform OS3 spec to OS2 (scenario 11 - produces)", () => {
|
|
162
|
+
expect(transformToOS2(producesOS3 as any)).toEqual(producesOS2);
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it("should transform OS3 spec to OS2 (scenario 12 - request_response_ref)", () => {
|
|
166
|
+
expect(transformToOS2(requestResponseRefOS3 as any)).toEqual(requestResponseRefOS2);
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
it("should transform OS3 spec to OS2 (scenario 13 - servers)", () => {
|
|
170
|
+
expect(transformToOS2(serversOS3 as any)).toEqual(serversOS2);
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
it("should transform OS3 spec to OS2 (scenario 14 - slash_ref)", () => {
|
|
174
|
+
expect(transformToOS2(slashRefOS3 as any)).toEqual(slashRefOS2);
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
});
|