@tsed/schema 7.0.0-beta.4 → 7.0.0-beta.7
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/jest.config.js +3 -3
- package/lib/cjs/index.js +1 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/utils/generateSpec.js +4 -13
- package/lib/cjs/utils/generateSpec.js.map +1 -1
- package/lib/cjs/utils/transformToOS2.js +510 -0
- package/lib/cjs/utils/transformToOS2.js.map +1 -0
- package/lib/esm/index.js +1 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/utils/generateSpec.js +4 -13
- package/lib/esm/utils/generateSpec.js.map +1 -1
- package/lib/esm/utils/transformToOS2.js +504 -0
- package/lib/esm/utils/transformToOS2.js.map +1 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/utils/transformToOS2.d.ts +25 -0
- package/package.json +8 -8
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformToOS2.js","sourceRoot":"","sources":["../../../src/utils/transformToOS2.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,qCAAuC;AAEvC,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AAC3F,MAAM,iBAAiB,GAAG;IACxB,QAAQ;IACR,SAAS;IACT,SAAS;IACT,kBAAkB;IAClB,kBAAkB;IAClB,WAAW;IACX,WAAW;IACX,YAAY;IACZ,UAAU;IACV,UAAU;IACV,aAAa;IACb,eAAe;IACf,eAAe;IACf,sBAAsB;IACtB,SAAS;IACT,MAAM;IACN,SAAS;CACV,CAAC;AACF,MAAM,gBAAgB,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE3C,MAAM,sBAAsB,GAAG,iEAAiE,CAAC;AACjG,MAAM,oBAAoB,GAAwB;IAChD,4BAA4B,EAAE,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gBACL,OAAO,CAAC,IAAI,CAAC,qBAAqB,eAAe,QAAQ,OAAO,4BAA4B,CAAC,CAAC;aAC/F;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED,0BAA0B;QACxB,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,eAAe,EAAE;YACxC,IAAI,CAAC,IAAI,CAAC,mBAAmB,GAAG,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;YACxF,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC;SAC7C;IACH,CAAC;CACF;AA5cD,8BA4cC;AAED,SAAgB,cAAc,CAAC,IAAS;IACtC,OAAO,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;AACvC,CAAC;AAFD,wCAEC","sourcesContent":["\"use strict\";\nimport {OpenSpec2, OpenSpec3, OS3Operation} from \"@tsed/openspec\";\nimport {cleanObject} from \"@tsed/core\";\n\nconst HTTP_METHODS = [\"get\", \"put\", \"post\", \"delete\", \"options\", \"head\", \"patch\", \"trace\"];\nconst SCHEMA_PROPERTIES = [\n \"format\",\n \"minimum\",\n \"maximum\",\n \"exclusiveMinimum\",\n \"exclusiveMaximum\",\n \"minLength\",\n \"maxLength\",\n \"multipleOf\",\n \"minItems\",\n \"maxItems\",\n \"uniqueItems\",\n \"minProperties\",\n \"maxProperties\",\n \"additionalProperties\",\n \"pattern\",\n \"enum\",\n \"default\"\n];\nconst ARRAY_PROPERTIES = [\"type\", \"items\"];\n\nconst APPLICATION_JSON_REGEX = /^(application\\/json|[^;\\/ \\t]+\\/[^;\\/ \\t]+[+]json)[ \\t]*(;.*)?$/;\nconst SUPPORTED_MIME_TYPES: Record<string, any> = {\n APPLICATION_X_WWW_URLENCODED: \"application/x-www-form-urlencoded\",\n MULTIPART_FORM_DATA: \"multipart/form-data\"\n};\n\nfunction fixRef(ref: string) {\n return ref.replace(\"#/components/schemas/\", \"#/definitions/\").replace(\"#/components/\", \"#/x-components/\");\n}\n\nfunction fixRefs(obj: any) {\n if (Array.isArray(obj)) {\n obj.forEach(fixRefs);\n } else if (typeof obj === \"object\") {\n for (let key in obj) {\n if (key === \"$ref\") {\n obj.$ref = fixRef(obj.$ref);\n } else {\n fixRefs(obj[key]);\n }\n }\n }\n}\n\nfunction isJsonMimeType(type: string) {\n return new RegExp(APPLICATION_JSON_REGEX, \"i\").test(type);\n}\n\nfunction getSupportedMimeTypes(content: any) {\n const MIME_VALUES = Object.keys(SUPPORTED_MIME_TYPES).map((key) => {\n return SUPPORTED_MIME_TYPES[key];\n });\n return Object.keys(content).filter((key) => {\n return MIME_VALUES.indexOf(key) > -1 || isJsonMimeType(key);\n });\n}\n\nexport function transformSecurity(securitySchemes: any) {\n function map(security: any) {\n const {scheme, type, name, bearerFormat, flows, ...props} = security;\n\n switch (type) {\n case \"http\":\n if (scheme === \"basic\") {\n return {\n ...props,\n type: scheme\n };\n }\n\n if (scheme === \"bearer\") {\n return {\n ...props,\n type: \"apiKey\",\n name: \"Authorization\",\n in: \"header\"\n };\n }\n break;\n case \"oauth2\":\n const flowName = Object.keys(flows)[0];\n const flow = flows[flowName];\n let flowType = flowName;\n\n if (flowType === \"clientCredentials\") {\n flowType = \"application\";\n } else if (flowType === \"authorizationCode\") {\n flowType = \"accessCode\";\n }\n\n return {\n type,\n flow: flowType,\n authorizationUrl: flow.authorizationUrl,\n tokenUrl: flow.tokenUrl,\n scopes: flow.scopes\n };\n }\n }\n\n return Object.entries(securitySchemes).reduce((securityDefinitions, [key, security]) => {\n return {\n ...securityDefinitions,\n [key]: map(security)\n };\n }, {});\n}\n\nexport function transformInformation(server: any) {\n let serverUrl = server.url;\n\n const variables = server[\"variables\"] || {};\n\n for (const variable in variables) {\n const variableObject = variables[variable] || {};\n if (variableObject[\"default\"]) {\n const re = RegExp(`{${variable}}`, \"g\");\n serverUrl = serverUrl.replace(re, variableObject[\"default\"]);\n }\n }\n\n const url = new URL(serverUrl);\n\n return {\n host: url.host ? url.host : undefined,\n basePath: url.pathname,\n schemes: url.protocol !== null ? [url.protocol.substring(0, url.protocol.length - 1)] : undefined\n };\n}\n\nexport class Converter {\n private spec: any;\n\n constructor(spec: Partial<OpenSpec3>) {\n this.spec = JSON.parse(JSON.stringify(spec));\n }\n\n convertInfos() {\n const server = this.spec.servers && this.spec.servers[0];\n\n if (server) {\n return transformInformation(server);\n }\n\n return {};\n }\n\n resolveReference(base: any, obj: any, shouldClone: boolean) {\n if (!obj || !obj.$ref) {\n return obj;\n }\n\n const ref: string = obj.$ref;\n\n if (ref.startsWith(\"#\")) {\n const keys = ref.split(\"/\").map((k) => k.replace(/~1/g, \"/\").replace(/~0/g, \"~\"));\n keys.shift();\n\n let cur = base;\n keys.forEach((k) => {\n cur = cur[k];\n });\n\n return shouldClone ? JSON.parse(JSON.stringify(cur)) : cur;\n }\n }\n\n convert() {\n const spec = {\n swagger: \"2.0\",\n ...this.convertInfos(),\n paths: this.spec.paths ? this.convertOperations(this.spec.paths, this.spec) : undefined\n };\n\n if (this.spec.components) {\n this.convertSchemas();\n this.convertSecurityDefinitions();\n\n this.spec[\"x-components\"] = this.spec.components;\n delete this.spec.components;\n\n fixRefs(this.spec);\n }\n\n delete this.spec.servers;\n delete this.spec.openapi;\n delete this.spec[\"x-components\"];\n\n return cleanObject({\n ...spec,\n ...this.spec\n });\n }\n\n convertOperations(paths: any, spec: any) {\n return Object.entries(paths).reduce((paths, [path, operation]) => {\n const pathObject = (paths[path] = this.resolveReference({...spec, paths}, operation, true));\n\n this.convertParameters(pathObject); // converts common parameters\n\n Object.keys(pathObject).forEach((method) => {\n if (HTTP_METHODS.indexOf(method) >= 0) {\n const operation = (pathObject[method] = this.resolveReference({...spec, paths}, pathObject[method], true));\n\n this.convertOperationParameters(operation);\n this.convertResponses(operation);\n }\n });\n\n return paths;\n }, paths);\n }\n\n convertOperationParameters(operation: OS3Operation) {\n let content, contentKey, mediaRanges, mediaTypes;\n operation.parameters = operation.parameters || [];\n\n if (operation.requestBody) {\n let param = this.resolveReference(this.spec, operation.requestBody, true);\n\n // fixing external $ref in body\n if (operation.requestBody.content) {\n const type = getSupportedMimeTypes(operation.requestBody.content)[0];\n const structuredObj: any = {content: {}};\n const data = operation.requestBody.content[type];\n\n if (data && data.schema && data.schema.$ref && !data.schema.$ref.startsWith(\"#\")) {\n param = this.resolveReference(this.spec, data.schema, true);\n structuredObj[\"content\"][`${type}`] = {schema: param};\n param = structuredObj;\n }\n }\n\n param.name = \"body\";\n content = param.content;\n\n if (content && Object.keys(content).length) {\n mediaRanges = Object.keys(content).filter((mediaRange) => mediaRange.indexOf(\"/\") > 0);\n mediaTypes = mediaRanges.filter((range) => range.indexOf(\"*\") < 0);\n contentKey = getSupportedMimeTypes(content)[0];\n\n delete param.content;\n\n if ([SUPPORTED_MIME_TYPES.APPLICATION_X_WWW_URLENCODED, SUPPORTED_MIME_TYPES.MULTIPART_FORM_DATA].includes(contentKey)) {\n (operation as any).consumes = mediaTypes;\n\n param.in = \"formData\";\n param.schema = content[contentKey].schema;\n param.schema = this.resolveReference(this.spec, param.schema, true);\n\n if (param.schema.type === \"object\" && param.schema.properties) {\n const required = param.schema.required || [];\n\n Object.keys(param.schema.properties).forEach((name) => {\n const schema = param.schema.properties[name];\n\n // readOnly properties should not be sent in requests\n if (!schema.readOnly) {\n const formDataParam: any = {\n name,\n in: \"formData\",\n schema\n };\n if (required.indexOf(name) >= 0) {\n formDataParam.required = true;\n }\n\n operation.parameters?.push(formDataParam);\n }\n });\n } else {\n operation.parameters.push(param);\n }\n } else if (contentKey) {\n (operation as any).consumes = mediaTypes;\n param.in = \"body\";\n param.schema = content[contentKey].schema;\n operation.parameters.push(param);\n } else if (mediaRanges) {\n (operation as any).consumes = mediaTypes || [\"application/octet-stream\"];\n param.in = \"body\";\n param.name = param.name || \"file\";\n delete param.type;\n\n param.schema = content[mediaRanges[0]].schema || {\n type: \"string\",\n format: \"binary\"\n };\n\n operation.parameters.push(param);\n }\n\n if (param.schema) {\n this.convertSchema(param.schema, \"request\");\n }\n }\n\n delete operation.requestBody;\n }\n this.convertParameters(operation);\n }\n\n convertParameters(obj: any) {\n if (obj.parameters === undefined) {\n return;\n }\n\n obj.parameters = obj.parameters || [];\n\n (obj.parameters || []).forEach((param: any, i: number) => {\n param = obj.parameters[i] = this.resolveReference(this.spec, param, false);\n\n if (param.in !== \"body\") {\n this.copySchemaProperties(param, SCHEMA_PROPERTIES);\n this.copySchemaProperties(param, ARRAY_PROPERTIES);\n this.copySchemaXProperties(param);\n\n if (!param.description) {\n const schema = this.resolveReference(this.spec, param.schema, false);\n if (!!schema && schema.description) {\n param.description = schema.description;\n }\n }\n\n if (param.example !== undefined) {\n param[\"x-example\"] = param.example;\n }\n\n delete param.schema;\n delete param.allowReserved;\n delete param.example;\n }\n\n if (param.type === \"array\") {\n let style = param.style || (param.in === \"query\" || param.in === \"cookie\" ? \"form\" : \"simple\");\n\n switch (style) {\n case \"matrix\":\n param.collectionFormat = param.explode ? undefined : \"csv\";\n break;\n case \"label\":\n param.collectionFormat = undefined;\n break;\n case \"simple\":\n param.collectionFormat = \"csv\";\n break;\n case \"spaceDelimited\":\n param.collectionFormat = \"ssv\";\n break;\n case \"pipeDelimited\":\n param.collectionFormat = \"pipes\";\n break;\n case \"deepOpbject\":\n param.collectionFormat = \"multi\";\n break;\n case \"form\":\n param.collectionFormat = param.explode === false ? \"csv\" : \"multi\";\n break;\n }\n }\n\n delete param.style;\n delete param.explode;\n });\n }\n\n copySchemaProperties(obj: any, props: any[]) {\n let schema = this.resolveReference(this.spec, obj.schema, true);\n\n if (!schema) {\n return;\n }\n\n props.forEach((prop) => {\n const value = schema[prop];\n\n if (prop === \"additionalProperties\" && typeof value === \"boolean\") {\n return;\n }\n\n if (value !== undefined) {\n obj[prop] = value;\n }\n });\n }\n\n copySchemaXProperties(obj: Record<string, any>) {\n let schema = this.resolveReference(this.spec, obj.schema, true);\n if (!schema) {\n return;\n }\n\n Object.keys(schema).forEach((propName) => {\n if (Reflect.hasOwnProperty.call(schema, propName) && !Reflect.hasOwnProperty.call(obj, propName) && propName.startsWith(\"x-\")) {\n obj[propName] = schema[propName];\n }\n });\n }\n\n convertResponses(operation: Record<string, any>) {\n // var anySchema, code, content, jsonSchema, mediaRange, mediaType, response, resolved, headers\n\n Object.keys(operation.responses || {}).forEach((code) => {\n const response = (operation.responses[code] = this.resolveReference(this.spec, operation.responses[code], true));\n\n if (response.content) {\n let anySchema: any = null;\n let jsonSchema: any = null;\n\n Object.keys(response.content).forEach((mediaRange) => {\n // produces and examples only allow media types, not ranges\n // use application/octet-stream as a catch-all type\n const mediaType = mediaRange.indexOf(\"*\") < 0 ? mediaRange : \"application/octet-stream\";\n\n if (!operation.produces) {\n operation.produces = [mediaType];\n } else if (operation.produces.indexOf(mediaType) < 0) {\n operation.produces.push(mediaType);\n }\n\n const content = response.content[mediaRange];\n anySchema = anySchema || content.schema;\n\n if (!jsonSchema && isJsonMimeType(mediaType)) {\n jsonSchema = content.schema;\n }\n\n if (content.example) {\n response.examples = response.examples || {};\n response.examples[mediaType] = content.example;\n }\n });\n\n if (anySchema) {\n response.schema = jsonSchema || anySchema;\n const resolved = this.resolveReference(this.spec, response.schema, true);\n\n if (resolved && response.schema.$ref && !response.schema.$ref.startsWith(\"#\")) {\n response.schema = resolved;\n }\n\n this.convertSchema(response.schema, \"response\");\n }\n }\n\n Object.keys(response.headers || {}).forEach((header) => {\n // Always resolve headers when converting to v2.\n const resolved = this.resolveReference(this.spec, response.headers[header], true);\n\n // Headers should be converted like parameters.\n if (resolved.schema) {\n resolved.type = resolved.schema.type;\n resolved.format = resolved.schema.format;\n delete resolved.schema;\n }\n\n response.headers[header] = resolved;\n });\n\n delete response.content;\n });\n }\n\n convertSchema(def: any, operationDirection?: any) {\n if (def.oneOf) {\n delete def.oneOf;\n\n if (def.discriminator) {\n delete def.discriminator;\n }\n }\n\n if (def.anyOf) {\n delete def.anyOf;\n\n if (def.discriminator) {\n delete def.discriminator;\n }\n }\n\n if (def.allOf) {\n for (const i in def.allOf) {\n this.convertSchema(def.allOf[i], operationDirection);\n }\n }\n\n if (def.discriminator) {\n if (def.discriminator.mapping) {\n this.convertDiscriminatorMapping(def.discriminator.mapping);\n }\n\n def.discriminator = def.discriminator.propertyName;\n }\n\n switch (def.type) {\n case \"object\":\n if (def.properties) {\n Object.keys(def.properties).forEach((propName) => {\n if (def.properties[propName].writeOnly === true && operationDirection === \"response\") {\n delete def.properties[propName];\n } else {\n this.convertSchema(def.properties[propName], operationDirection);\n delete def.properties[propName].writeOnly;\n }\n });\n }\n break;\n case \"array\":\n if (def.items) {\n this.convertSchema(def.items, operationDirection);\n }\n }\n\n if (def.nullable) {\n def[\"x-nullable\"] = true;\n delete def.nullable;\n }\n\n // OpenAPI 3 has boolean \"deprecated\" on Schema, OpenAPI 2 does not\n // Convert to x-deprecated for Autorest (and perhaps others)\n if (def[\"deprecated\"] !== undefined) {\n // Move to x-deprecated, unless it is already defined\n if (def[\"x-deprecated\"] === undefined) {\n def[\"x-deprecated\"] = def.deprecated;\n }\n delete def.deprecated;\n }\n }\n\n convertSchemas() {\n this.spec.definitions = this.spec.components.schemas;\n\n Object.keys(this.spec.definitions || {}).forEach((defName) => {\n this.convertSchema(this.spec.definitions[defName]);\n });\n\n delete this.spec.components.schemas;\n }\n\n convertDiscriminatorMapping(mapping: any) {\n Object.keys(mapping).forEach((payload) => {\n const schemaNameOrRef = mapping[payload];\n\n if (typeof schemaNameOrRef !== \"string\") {\n console.warn(`Ignoring ${schemaNameOrRef} for ${payload} in discriminator.mapping.`);\n return;\n }\n\n // payload may be a schema name or JSON Reference string.\n // OAS3 spec limits schema names to ^[a-zA-Z0-9._-]+$\n // Note: Valid schema name could be JSON file name without extension.\n // Prefer schema name, with file name as fallback.\n let schema;\n if (/^[a-zA-Z0-9._-]+$/.test(schemaNameOrRef)) {\n try {\n schema = this.resolveReference(this.spec, {$ref: `#/components/schemas/${schemaNameOrRef}`}, false);\n } catch (err) {\n console.debug(`Error resolving ${schemaNameOrRef} for ${payload} as schema name in discriminator.mapping: ${err}`);\n }\n }\n\n // schemaNameRef is not a schema name. Try to resolve as JSON Ref.\n if (!schema) {\n try {\n schema = this.resolveReference(this.spec, {$ref: schemaNameOrRef}, false);\n } catch (err) {\n console.debug(`Error resolving ${schemaNameOrRef} for ${payload} in discriminator.mapping: ${err}`);\n }\n }\n\n if (schema) {\n // Swagger Codegen + OpenAPI Generator extension\n // https://github.com/swagger-api/swagger-codegen/pull/4252\n schema[\"x-discriminator-value\"] = payload;\n\n // AutoRest extension\n // https://github.com/Azure/autorest/pull/474\n schema[\"x-ms-discriminator-value\"] = payload;\n } else {\n console.warn(`Unable to resolve ${schemaNameOrRef} for ${payload} in discriminator.mapping.`);\n }\n });\n }\n\n convertSecurityDefinitions() {\n if (this.spec.components.securitySchemes) {\n this.spec.securityDefinitions = transformSecurity(this.spec.components.securitySchemes);\n delete this.spec.components.securitySchemes;\n }\n }\n}\n\nexport function transformToOS2(spec: any): Partial<OpenSpec2> {\n return new Converter(spec).convert();\n}\n"]}
|
package/lib/esm/index.js
CHANGED
|
@@ -147,4 +147,5 @@ export * from "./utils/ref.js";
|
|
|
147
147
|
export * from "./utils/serializeEnumValues.js";
|
|
148
148
|
export * from "./utils/toJsonMapCollection.js";
|
|
149
149
|
export * from "./utils/toJsonRegex.js";
|
|
150
|
+
export * from "./utils/transformToOS2.js";
|
|
150
151
|
//# sourceMappingURL=index.js.map
|
package/lib/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mCAAmC,CAAC;AAClD,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACv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;AAC5C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./components/anyMapper\";\nexport * from \"./components/classMapper\";\nexport * from \"./components/genericsMapper\";\nexport * from \"./components/inheritedClassMapper\";\nexport * from \"./components/itemMapper\";\nexport * from \"./components/lazyRefMapper\";\nexport * from \"./components/mapMapper\";\nexport * from \"./components/objectMapper\";\nexport * from \"./components/ofMapper\";\nexport * from \"./components/propertiesMapper\";\nexport * from \"./components/schemaMapper\";\nexport * from \"./constants/httpMethods\";\nexport * from \"./constants/httpStatusMessages\";\nexport * from \"./decorators/class/children\";\nexport * from \"./decorators/collections/collectionContains\";\nexport * from \"./decorators/collections/collectionOf\";\nexport * from \"./decorators/collections/maxItems\";\nexport * from \"./decorators/collections/maxProperties\";\nexport * from \"./decorators/collections/minItems\";\nexport * from \"./decorators/collections/minProperties\";\nexport * from \"./decorators/collections/uniqueItems\";\nexport * from \"./decorators/common/additionalProperties\";\nexport * from \"./decorators/common/allOf\";\nexport * from \"./decorators/common/allow\";\nexport * from \"./decorators/common/any\";\nexport * from \"./decorators/common/anyOf\";\nexport * from \"./decorators/common/const\";\nexport * from \"./decorators/common/customKey\";\nexport * from \"./decorators/common/default\";\nexport * from \"./decorators/common/description\";\nexport * from \"./decorators/common/enum\";\nexport * from \"./decorators/common/example\";\nexport * from \"./decorators/common/examples\";\nexport * from \"./decorators/common/exclusiveMaximum\";\nexport * from \"./decorators/common/exclusiveMinimum\";\nexport * from \"./decorators/common/format\";\nexport * from \"./decorators/common/forwardGroups\";\nexport * from \"./decorators/common/groups\";\nexport * from \"./decorators/common/hidden\";\nexport * from \"./decorators/common/ignore\";\nexport * from \"./decorators/common/integer\";\nexport * from \"./decorators/common/jsonEntityFn\";\nexport * from \"./decorators/common/maxLength\";\nexport * from \"./decorators/common/maximum\";\nexport * from \"./decorators/common/minLength\";\nexport * from \"./decorators/common/minimum\";\nexport * from \"./decorators/common/multipleOf\";\nexport * from \"./decorators/common/name\";\nexport * from \"./decorators/common/nullable\";\nexport * from \"./decorators/common/oneOf\";\nexport * from \"./decorators/common/optional\";\nexport * from \"./decorators/common/pattern\";\nexport * from \"./decorators/common/property\";\nexport * from \"./decorators/common/readOnly\";\nexport * from \"./decorators/common/recordOf\";\nexport * from \"./decorators/common/required\";\nexport * from \"./decorators/common/requiredGroups\";\nexport * from \"./decorators/common/schema\";\nexport * from \"./decorators/common/title\";\nexport * from \"./decorators/common/writeOnly\";\nexport * from \"./decorators/config/jsonEntityComponent\";\nexport * from \"./decorators/generics/genericOf\";\nexport * from \"./decorators/generics/generics\";\nexport * from \"./decorators/operations/acceptMime\";\nexport * from \"./decorators/operations/consumes\";\nexport * from \"./decorators/operations/contentType\";\nexport * from \"./decorators/operations/deprecated\";\nexport * from \"./decorators/operations/header\";\nexport * from \"./decorators/operations/in\";\nexport * from \"./decorators/operations/inFile\";\nexport * from \"./decorators/operations/location\";\nexport * from \"./decorators/operations/operationId\";\nexport * from \"./decorators/operations/operationPath\";\nexport * from \"./decorators/operations/partial\";\nexport * from \"./decorators/operations/path\";\nexport * from \"./decorators/operations/produces\";\nexport * from \"./decorators/operations/redirect\";\nexport * from \"./decorators/operations/returns\";\nexport * from \"./decorators/operations/route\";\nexport * from \"./decorators/operations/security\";\nexport * from \"./decorators/operations/status\";\nexport * from \"./decorators/operations/summary\";\nexport * from \"./decorators/operations/tags\";\nexport * from \"./decorators/operations/view\";\nexport * from \"./domain/DecoratorContext\";\nexport * from \"./domain/JsonAliasMap\";\nexport * from \"./domain/JsonClassStore\";\nexport * from \"./domain/JsonEntityStore\";\nexport * from \"./domain/JsonFormatTypes\";\nexport * from \"./domain/JsonLazyRef\";\nexport * from \"./domain/JsonMap\";\nexport * from \"./domain/JsonMethodStore\";\nexport * from \"./domain/JsonOperation\";\nexport * from \"./domain/JsonOperationPathsMap\";\nexport * from \"./domain/JsonOperationRoute\";\nexport * from \"./domain/JsonParameter\";\nexport * from \"./domain/JsonParameterStore\";\nexport * from \"./domain/JsonParameterTypes\";\nexport * from \"./domain/JsonPropertyStore\";\nexport * from \"./domain/JsonRequestBody\";\nexport * from \"./domain/JsonResponse\";\nexport * from \"./domain/JsonSchema\";\nexport * from \"./domain/SpecTypes\";\nexport * from \"./hooks/alterIgnore\";\nexport * from \"./hooks/alterOneOf\";\nexport * from \"./hooks/alterRequiredGroups\";\nexport * from \"./interfaces/IgnoreCallback\";\nexport * from \"./interfaces/JsonHookContext\";\nexport * from \"./interfaces/JsonOpenSpec\";\nexport * from \"./interfaces/JsonSchemaOptions\";\nexport * from \"./registries/JsonSchemaMapperContainer\";\nexport * from \"./utils/buildPath\";\nexport * from \"./utils/concatParameters\";\nexport * from \"./utils/concatPath\";\nexport * from \"./utils/defineStatusModel\";\nexport * from \"./utils/from\";\nexport * from \"./utils/generateSpec\";\nexport * from \"./utils/generics\";\nexport * from \"./utils/getComputedType\";\nexport * from \"./utils/getInheritedStores\";\nexport * from \"./utils/getJsonEntityStore\";\nexport * from \"./utils/getJsonPathParameters\";\nexport * from \"./utils/getJsonSchema\";\nexport * from \"./utils/getJsonType\";\nexport * from \"./utils/getOperationsRoutes\";\nexport * from \"./utils/getOperationsStores\";\nexport * from \"./utils/getPropertiesStores\";\nexport * from \"./utils/getRequiredProperties\";\nexport * from \"./utils/getSpec\";\nexport * from \"./utils/getSpecType\";\nexport * from \"./utils/isSuccessStatus\";\nexport * from \"./utils/mapHeaders\";\nexport * from \"./utils/mapNullableType\";\nexport * from \"./utils/mapOpenSpec\";\nexport * from \"./utils/mapOpenSpec2\";\nexport * from \"./utils/mapOpenSpec3\";\nexport * from \"./utils/mapOpenSpecInfo\";\nexport * from \"./utils/mapRouteOptions\";\nexport * from \"./utils/matchGroups\";\nexport * from \"./utils/mergeOperation\";\nexport * from \"./utils/mergeSpec\";\nexport * from \"./utils/operationIdFormatter\";\nexport * from \"./utils/ref\";\nexport * from \"./utils/serializeEnumValues\";\nexport * from \"./utils/toJsonMapCollection\";\nexport * from \"./utils/toJsonRegex\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mCAAmC,CAAC;AAClD,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6CAA6C,CAAC;AAC5D,cAAc,uCAAuC,CAAC;AACtD,cAAc,mCAAmC,CAAC;AAClD,cAAc,wCAAwC,CAAC;AACvD,cAAc,mCAAmC,CAAC;AAClD,cAAc,wCAAwC,CAAC;AACvD,cAAc,sCAAsC,CAAC;AACrD,cAAc,0CAA0C,CAAC;AACzD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iCAAiC,CAAC;AAChD,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,sCAAsC,CAAC;AACrD,cAAc,sCAAsC,CAAC;AACrD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mCAAmC,CAAC;AAClD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,C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C;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,aAAa,CAAC;AAC5B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./components/anyMapper\";\nexport * from \"./components/classMapper\";\nexport * from \"./components/genericsMapper\";\nexport * from \"./components/inheritedClassMapper\";\nexport * from \"./components/itemMapper\";\nexport * from \"./components/lazyRefMapper\";\nexport * from \"./components/mapMapper\";\nexport * from \"./components/objectMapper\";\nexport * from \"./components/ofMapper\";\nexport * from \"./components/propertiesMapper\";\nexport * from \"./components/schemaMapper\";\nexport * from \"./constants/httpMethods\";\nexport * from \"./constants/httpStatusMessages\";\nexport * from \"./decorators/class/children\";\nexport * from \"./decorators/collections/collectionContains\";\nexport * from \"./decorators/collections/collectionOf\";\nexport * from \"./decorators/collections/maxItems\";\nexport * from \"./decorators/collections/maxProperties\";\nexport * from \"./decorators/collections/minItems\";\nexport * from \"./decorators/collections/minProperties\";\nexport * from \"./decorators/collections/uniqueItems\";\nexport * from \"./decorators/common/additionalProperties\";\nexport * from \"./decorators/common/allOf\";\nexport * from \"./decorators/common/allow\";\nexport * from \"./decorators/common/any\";\nexport * from \"./decorators/common/anyOf\";\nexport * from \"./decorators/common/const\";\nexport * from \"./decorators/common/customKey\";\nexport * from \"./decorators/common/default\";\nexport * from \"./decorators/common/description\";\nexport * from \"./decorators/common/enum\";\nexport * from \"./decorators/common/example\";\nexport * from \"./decorators/common/examples\";\nexport * from \"./decorators/common/exclusiveMaximum\";\nexport * from \"./decorators/common/exclusiveMinimum\";\nexport * from \"./decorators/common/format\";\nexport * from \"./decorators/common/forwardGroups\";\nexport * from \"./decorators/common/groups\";\nexport * from \"./decorators/common/hidden\";\nexport * from \"./decorators/common/ignore\";\nexport * from \"./decorators/common/integer\";\nexport * from \"./decorators/common/jsonEntityFn\";\nexport * from \"./decorators/common/maxLength\";\nexport * from \"./decorators/common/maximum\";\nexport * from \"./decorators/common/minLength\";\nexport * from \"./decorators/common/minimum\";\nexport * from \"./decorators/common/multipleOf\";\nexport * from \"./decorators/common/name\";\nexport * from \"./decorators/common/nullable\";\nexport * from \"./decorators/common/oneOf\";\nexport * from \"./decorators/common/optional\";\nexport * from \"./decorators/common/pattern\";\nexport * from \"./decorators/common/property\";\nexport * from \"./decorators/common/readOnly\";\nexport * from \"./decorators/common/recordOf\";\nexport * from \"./decorators/common/required\";\nexport * from \"./decorators/common/requiredGroups\";\nexport * from \"./decorators/common/schema\";\nexport * from \"./decorators/common/title\";\nexport * from \"./decorators/common/writeOnly\";\nexport * from \"./decorators/config/jsonEntityComponent\";\nexport * from \"./decorators/generics/genericOf\";\nexport * from \"./decorators/generics/generics\";\nexport * from \"./decorators/operations/acceptMime\";\nexport * from \"./decorators/operations/consumes\";\nexport * from \"./decorators/operations/contentType\";\nexport * from \"./decorators/operations/deprecated\";\nexport * from \"./decorators/operations/header\";\nexport * from \"./decorators/operations/in\";\nexport * from \"./decorators/operations/inFile\";\nexport * from \"./decorators/operations/location\";\nexport * from \"./decorators/operations/operationId\";\nexport * from \"./decorators/operations/operationPath\";\nexport * from \"./decorators/operations/partial\";\nexport * from \"./decorators/operations/path\";\nexport * from \"./decorators/operations/produces\";\nexport * from \"./decorators/operations/redirect\";\nexport * from \"./decorators/operations/returns\";\nexport * from \"./decorators/operations/route\";\nexport * from \"./decorators/operations/security\";\nexport * from \"./decorators/operations/status\";\nexport * from \"./decorators/operations/summary\";\nexport * from \"./decorators/operations/tags\";\nexport * from \"./decorators/operations/view\";\nexport * from \"./domain/DecoratorContext\";\nexport * from \"./domain/JsonAliasMap\";\nexport * from \"./domain/JsonClassStore\";\nexport * from \"./domain/JsonEntityStore\";\nexport * from \"./domain/JsonFormatTypes\";\nexport * from \"./domain/JsonLazyRef\";\nexport * from \"./domain/JsonMap\";\nexport * from \"./domain/JsonMethodStore\";\nexport * from \"./domain/JsonOperation\";\nexport * from \"./domain/JsonOperationPathsMap\";\nexport * from \"./domain/JsonOperationRoute\";\nexport * from \"./domain/JsonParameter\";\nexport * from \"./domain/JsonParameterStore\";\nexport * from \"./domain/JsonParameterTypes\";\nexport * from \"./domain/JsonPropertyStore\";\nexport * from \"./domain/JsonRequestBody\";\nexport * from \"./domain/JsonResponse\";\nexport * from \"./domain/JsonSchema\";\nexport * from \"./domain/SpecTypes\";\nexport * from \"./hooks/alterIgnore\";\nexport * from \"./hooks/alterOneOf\";\nexport * from \"./hooks/alterRequiredGroups\";\nexport * from \"./interfaces/IgnoreCallback\";\nexport * from \"./interfaces/JsonHookContext\";\nexport * from \"./interfaces/JsonOpenSpec\";\nexport * from \"./interfaces/JsonSchemaOptions\";\nexport * from \"./registries/JsonSchemaMapperContainer\";\nexport * from \"./utils/buildPath\";\nexport * from \"./utils/concatParameters\";\nexport * from \"./utils/concatPath\";\nexport * from \"./utils/defineStatusModel\";\nexport * from \"./utils/from\";\nexport * from \"./utils/generateSpec\";\nexport * from \"./utils/generics\";\nexport * from \"./utils/getComputedType\";\nexport * from \"./utils/getInheritedStores\";\nexport * from \"./utils/getJsonEntityStore\";\nexport * from \"./utils/getJsonPathParameters\";\nexport * from \"./utils/getJsonSchema\";\nexport * from \"./utils/getJsonType\";\nexport * from \"./utils/getOperationsRoutes\";\nexport * from \"./utils/getOperationsStores\";\nexport * from \"./utils/getPropertiesStores\";\nexport * from \"./utils/getRequiredProperties\";\nexport * from \"./utils/getSpec\";\nexport * from \"./utils/getSpecType\";\nexport * from \"./utils/isSuccessStatus\";\nexport * from \"./utils/mapHeaders\";\nexport * from \"./utils/mapNullableType\";\nexport * from \"./utils/mapOpenSpec\";\nexport * from \"./utils/mapOpenSpec2\";\nexport * from \"./utils/mapOpenSpec3\";\nexport * from \"./utils/mapOpenSpecInfo\";\nexport * from \"./utils/mapRouteOptions\";\nexport * from \"./utils/matchGroups\";\nexport * from \"./utils/mergeOperation\";\nexport * from \"./utils/mergeSpec\";\nexport * from \"./utils/operationIdFormatter\";\nexport * from \"./utils/ref\";\nexport * from \"./utils/serializeEnumValues\";\nexport * from \"./utils/toJsonMapCollection\";\nexport * from \"./utils/toJsonRegex\";\nexport * from \"./utils/transformToOS2\";\n"]}
|
|
@@ -5,6 +5,7 @@ import { getSpec } from "./getSpec.js";
|
|
|
5
5
|
import { getSpecTypeFromSpec } from "./getSpecType.js";
|
|
6
6
|
import { mergeSpec } from "./mergeSpec.js";
|
|
7
7
|
import { SpecTypes } from "../domain/SpecTypes.js";
|
|
8
|
+
import { transformToOS2 } from "./transformToOS2.js";
|
|
8
9
|
async function readSpec(path) {
|
|
9
10
|
if (fs.existsSync(path)) {
|
|
10
11
|
try {
|
|
@@ -31,20 +32,10 @@ export async function generateSpec({ tokens, ...options }) {
|
|
|
31
32
|
});
|
|
32
33
|
const specType = getSpecTypeFromSpec(defaultSpec);
|
|
33
34
|
let controllersSpec = getSpec(tokens, options);
|
|
35
|
+
const spec = mergeSpec(defaultSpec, controllersSpec);
|
|
34
36
|
if (specType === SpecTypes.SWAGGER) {
|
|
35
|
-
|
|
36
|
-
const { convert } = await import("api-spec-converter");
|
|
37
|
-
const { spec } = await convert({
|
|
38
|
-
from: "openapi_3",
|
|
39
|
-
to: "swagger_2",
|
|
40
|
-
source: {
|
|
41
|
-
...controllersSpec,
|
|
42
|
-
openapi: "3.0.1"
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
controllersSpec = spec;
|
|
46
|
-
delete controllersSpec["x-components"];
|
|
37
|
+
return transformToOS2(spec);
|
|
47
38
|
}
|
|
48
|
-
return
|
|
39
|
+
return spec;
|
|
49
40
|
}
|
|
50
41
|
//# sourceMappingURL=generateSpec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateSpec.js","sourceRoot":"","sources":["../../../src/utils/generateSpec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAC,OAAO,EAA0C,MAAM,WAAW,CAAC;AAC3E,OAAO,EAAC,mBAAmB,EAAC,MAAM,eAAe,CAAC;AAClD,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AACtC,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"generateSpec.js","sourceRoot":"","sources":["../../../src/utils/generateSpec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAC,OAAO,EAA0C,MAAM,WAAW,CAAC;AAC3E,OAAO,EAAC,mBAAmB,EAAC,MAAM,eAAe,CAAC;AAClD,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AACtC,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAWhD,KAAK,UAAU,QAAQ,CAAC,IAAY;IAClC,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;QACvB,IAAI;YACF,OAAO,MAAM,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAC,QAAQ,EAAE,MAAM,EAAC,CAAC,CAAC;SACpD;QAAC,OAAO,CAAC,EAAE,GAAE;KACf;IAED,0BAA0B;IAC1B,OAAO,EAAE,CAAC;AACZ,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,EAAC,MAAM,EAAE,GAAG,OAAO,EAAsB;IAC1E,MAAM,EAAC,OAAO,GAAG,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAC,GAAG,OAAO,CAAC;IACxE,MAAM,QAAQ,GAAmC,QAAQ,CAAC,CAAC,CAAC,MAAM,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAE1F,MAAM,WAAW,GAAG,WAAW,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE;QAC7D,QAAQ;QACR,OAAO;QACP,WAAW;QACX,WAAW;KACZ,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAG,mBAAmB,CAAC,WAAW,CAAC,CAAC;IAElD,IAAI,eAAe,GAAQ,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpD,MAAM,IAAI,GAAQ,SAAS,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC;IAE1D,IAAI,QAAQ,KAAK,SAAS,CAAC,OAAO,EAAE;QAClC,OAAO,cAAc,CAAC,IAAI,CAAQ,CAAC;KACpC;IAED,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import fs from \"fs-extra\";\nimport {getValue} from \"@tsed/core\";\nimport {OpenSpec2, OpenSpec3} from \"@tsed/openspec\";\nimport {mapOpenSpec} from \"./mapOpenSpec\";\nimport {getSpec, JsonTokenOptions, SpecSerializerOptions} from \"./getSpec\";\nimport {getSpecTypeFromSpec} from \"./getSpecType\";\nimport {mergeSpec} from \"./mergeSpec\";\nimport {SpecTypes} from \"../domain/SpecTypes\";\nimport {transformToOS2} from \"./transformToOS2\";\n\nexport interface GenerateSpecOptions extends Omit<SpecSerializerOptions, \"specType\"> {\n tokens: JsonTokenOptions;\n version?: string;\n acceptMimes?: string;\n specPath?: string;\n specVersion?: string;\n spec?: any;\n}\n\nasync function readSpec(path: string) {\n if (fs.existsSync(path)) {\n try {\n return await fs.readJSON(path, {encoding: \"utf8\"});\n } catch (e) {}\n }\n\n /* istanbul ignore next */\n return {};\n}\n\n/**\n * Generate OpenAPI spec from multiple sources (models, files, conf)\n * @param tokens\n * @param options\n */\nexport async function generateSpec({tokens, ...options}: GenerateSpecOptions): Promise<OpenSpec2 | OpenSpec3> {\n const {version = \"1.0.0\", acceptMimes, specPath, specVersion} = options;\n const fileSpec: Partial<OpenSpec2 | OpenSpec3> = specPath ? await readSpec(specPath) : {};\n\n const defaultSpec = mapOpenSpec(getValue(options, \"spec\", {}), {\n fileSpec,\n version,\n specVersion,\n acceptMimes\n });\n\n const specType = getSpecTypeFromSpec(defaultSpec);\n\n let controllersSpec: any = getSpec(tokens, options);\n const spec: any = mergeSpec(defaultSpec, controllersSpec);\n\n if (specType === SpecTypes.SWAGGER) {\n return transformToOS2(spec) as any;\n }\n\n return spec;\n}\n"]}
|