@midwayjs/swagger 3.0.0-beta.17 → 3.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.
Files changed (29) hide show
  1. package/dist/common/enum.utils.js.map +1 -0
  2. package/dist/common/httpStatus.js.map +1 -0
  3. package/dist/config/config.default.js.map +1 -0
  4. package/dist/configuration.js.map +1 -0
  5. package/dist/constants.js.map +1 -0
  6. package/dist/decorators/api-basic.decorator.js.map +1 -0
  7. package/dist/decorators/api-bearer.decorator.js.map +1 -0
  8. package/dist/decorators/api-body.decorator.js.map +1 -0
  9. package/dist/decorators/api-cookie.decorator.js.map +1 -0
  10. package/dist/decorators/api-exclude-controller.decorator.js.map +1 -0
  11. package/dist/decorators/api-exclude-endpoint.decorator.js.map +1 -0
  12. package/dist/decorators/api-extension.decorator.js.map +1 -0
  13. package/dist/decorators/api-header.decorator.js.map +1 -0
  14. package/dist/decorators/api-oauth2.decorator.js.map +1 -0
  15. package/dist/decorators/api-operation.decorator.js.map +1 -0
  16. package/dist/decorators/api-param.decorator.js.map +1 -0
  17. package/dist/decorators/api-property.decorator.js.map +1 -0
  18. package/dist/decorators/api-query.decorator.js.map +1 -0
  19. package/dist/decorators/api-response.decorator.js.map +1 -0
  20. package/dist/decorators/api-security.decorator.js.map +1 -0
  21. package/dist/decorators/api-tags.decorator.js.map +1 -0
  22. package/dist/decorators/helpers.js.map +1 -0
  23. package/dist/decorators/index.js.map +1 -0
  24. package/dist/documentBuilder.js.map +1 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/interfaces/index.js.map +1 -0
  27. package/dist/swaggerExplorer.js.map +1 -0
  28. package/dist/swaggerMiddleware.js.map +1 -0
  29. package/package.json +9 -8
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enum.utils.js","sourceRoot":"","sources":["../../src/common/enum.utils.ts"],"names":[],"mappings":";;;AAMA,SAAgB,aAAa,CAAC,QAAyB;IACrD,IAAI,KAAK,CAAC,OAAO,C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AAC;QAC7B,IAAI,EAAE,UAAU;KACjB,CAAC;IAEF,IAAI,gBAAgB,CAAC,QAAQ,EAAE;QAC7B,eAAe,CAAC,QAAQ,GAAG,gBAAgB,CAAC,QAAQ,CAAC;KACtD;AACH,CAAC;AAlBD,gDAkBC;AAED,SAAgB,aAAa,CAC3B,eAA6C,EAC7C,gBAA8C;IAE9C,MAAM,WAAW,GAAiB,eAAe,CAAC,MAAM,IAAI,EAAE,CAAC;IAC/D,MAAM,UAAU,GAAG,aAAa,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAExD,eAAe,CAAC,MAAM,GAAG,WAAW,CAAC;IACrC,WAAW,CAAC,IAAI,GAAG,UAAU,CAAC;IAC9B,WAAW,CAAC,IAAI,GAAG,WAAW,CAAC,UAAU,CAAC,CAAC;IAE3C,IAAI,gBAAgB,CAAC,QAAQ,EAAE;QAC7B,eAAe,CAAC,QAAQ,GAAG,gBAAgB,CAAC,QAAQ,CAAC;KACtD;AACH,CAAC;AAdD,sCAcC;AAEM,MAAM,WAAW,GAAG,CACzB,GAAwB,EACd,EAAE,CAAC,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,IAAI,CAAC;AAF1B,QAAA,WAAW,eAEe;AAEhC,MAAM,aAAa,GAAG,CAC3B,GAAwB,EACd,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC;AAFX,QAAA,aAAa,iBAEF;AAEjB,MAAM,cAAc,GAAG,CAAC,QAA8B,EAAE,EAAE,WAC/D,OAAA,QAAQ,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,KAAI,MAAA,QAAQ,CAAC,KAAK,0CAAG,MAAM,CAAC,CAAA,CAAC,CAAA,EAAA,CAAC;AADrD,QAAA,cAAc,kBACuC","sourcesContent":["import {\n SchemaObject,\n SchemaObjectMetadata,\n SwaggerEnumType,\n} from '../interfaces';\n\nexport function getEnumValues(enumType: SwaggerEnumType): string[] | number[] {\n if (Array.isArray(enumType)) {\n return enumType as string[];\n }\n if (typeof enumType !== 'object') {\n return [];\n }\n\n const values = [];\n const uniqueValues = {};\n\n for (const key in enumType) {\n const value = enumType[key];\n /* eslint-disable no-prototype-builtins */\n // filter out cases where enum key also becomes its value (A: B, B: A)\n if (\n !uniqueValues.hasOwnProperty(value) &&\n !uniqueValues.hasOwnProperty(key)\n ) {\n values.push(value);\n uniqueValues[value] = value;\n }\n }\n return values;\n}\n\nexport function getEnumType(values: (string | number)[]): 'string' | 'number' {\n const hasString = values.filter(s => typeof s === 'string').length > 0;\n return hasString ? 'string' : 'number';\n}\n\nexport function addEnumArraySchema(\n paramDefinition: Partial<Record<'schema' | 'isArray' | 'enumName', any>>,\n decoratorOptions: Partial<Record<'enum' | 'enumName', any>>\n) {\n const paramSchema: SchemaObject = paramDefinition.schema || {};\n paramDefinition.schema = paramSchema;\n paramSchema.type = 'array';\n delete paramDefinition.isArray;\n\n const enumValues = getEnumValues(decoratorOptions.enum);\n paramSchema.items = {\n type: getEnumType(enumValues),\n enum: enumValues,\n };\n\n if (decoratorOptions.enumName) {\n paramDefinition.enumName = decoratorOptions.enumName;\n }\n}\n\nexport function addEnumSchema(\n paramDefinition: Partial<Record<string, any>>,\n decoratorOptions: Partial<Record<string, any>>\n) {\n const paramSchema: SchemaObject = paramDefinition.schema || {};\n const enumValues = getEnumValues(decoratorOptions.enum);\n\n paramDefinition.schema = paramSchema;\n paramSchema.enum = enumValues;\n paramSchema.type = getEnumType(enumValues);\n\n if (decoratorOptions.enumName) {\n paramDefinition.enumName = decoratorOptions.enumName;\n }\n}\n\nexport const isEnumArray = <T extends Partial<Record<'isArray' | 'enum', any>>>(\n obj: Record<string, any>\n): obj is T => obj.isArray && obj.enum;\n\nexport const isEnumDefined = <T extends Partial<Record<'enum', any>>>(\n obj: Record<string, any>\n): obj is T => obj.enum;\n\nexport const isEnumMetadata = (metadata: SchemaObjectMetadata) =>\n metadata.enum || (metadata.isArray && metadata.items?.['enum']);\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"httpStatus.js","sourceRoot":"","sources":["../../src/common/httpStatus.ts"],"names":[],"mappings":";;;AAAA,IAAY,UAiDX;AAjDD,WAAY,UAAU;IACpB,qDAAc,CAAA;IACd,2EAAyB,CAAA;IACzB,yDAAgB,CAAA;IAChB,yDAAgB,CAAA;IAChB,yCAAQ,CAAA;IACR,mDAAa,CAAA;IACb,qDAAc,CAAA;IACd,+FAAmC,CAAA;IACnC,yDAAgB,CAAA;IAChB,+DAAmB,CAAA;IACnB,mEAAqB,CAAA;IACrB,uDAAe,CAAA;IACf,uEAAuB,CAAA;IACvB,+CAAW,CAAA;IACX,uDAAe,CAAA;IACf,6DAAkB,CAAA;IAClB,yEAAwB,CAAA;IACxB,yEAAwB,CAAA;IACxB,2DAAiB,CAAA;IACjB,6DAAkB,CAAA;IAClB,qEAAsB,CAAA;IACtB,uDAAe,CAAA;IACf,uDAAe,CAAA;IACf,yEAAwB,CAAA;IACxB,iEAAoB,CAAA;IACpB,+FAAmC,CAAA;IACnC,mEAAqB,CAAA;IACrB,qDAAc,CAAA;IACd,6CAAU,CAAA;IACV,mEAAqB,CAAA;IACrB,2EAAyB,CAAA;IACzB,uEAAuB,CAAA;IACvB,6DAAkB,CAAA;IAClB,iFAA4B,CAAA;IAC5B,mGAAqC,CAAA;IACrC,yEAAwB,CAAA;IACxB,+DAAmB,CAAA;IACnB,2DAAiB,CAAA;IACjB,6EAA0B,CAAA;IAC1B,uEAAuB,CAAA;IACvB,+EAA2B,CAAA;IAC3B,uEAAuB,CAAA;IACvB,+EAA2B,CAAA;IAC3B,mEAAqB,CAAA;IACrB,2DAAiB,CAAA;IACjB,2EAAyB,CAAA;IACzB,mEAAqB,CAAA;IACrB,yFAAgC,CAAA;AAClC,CAAC,EAjDW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAiDrB","sourcesContent":["export enum HttpStatus {\n CONTINUE = 100,\n SWITCHING_PROTOCOLS = 101,\n PROCESSING = 102,\n EARLYHINTS = 103,\n OK = 200,\n CREATED = 201,\n ACCEPTED = 202,\n NON_AUTHORITATIVE_INFORMATION = 203,\n NO_CONTENT = 204,\n RESET_CONTENT = 205,\n PARTIAL_CONTENT = 206,\n AMBIGUOUS = 300,\n MOVED_PERMANENTLY = 301,\n FOUND = 302,\n SEE_OTHER = 303,\n NOT_MODIFIED = 304,\n TEMPORARY_REDIRECT = 307,\n PERMANENT_REDIRECT = 308,\n BAD_REQUEST = 400,\n UNAUTHORIZED = 401,\n PAYMENT_REQUIRED = 402,\n FORBIDDEN = 403,\n NOT_FOUND = 404,\n METHOD_NOT_ALLOWED = 405,\n NOT_ACCEPTABLE = 406,\n PROXY_AUTHENTICATION_REQUIRED = 407,\n REQUEST_TIMEOUT = 408,\n CONFLICT = 409,\n GONE = 410,\n LENGTH_REQUIRED = 411,\n PRECONDITION_FAILED = 412,\n PAYLOAD_TOO_LARGE = 413,\n URI_TOO_LONG = 414,\n UNSUPPORTED_MEDIA_TYPE = 415,\n REQUESTED_RANGE_NOT_SATISFIABLE = 416,\n EXPECTATION_FAILED = 417,\n I_AM_A_TEAPOT = 418,\n MISDIRECTED = 421,\n UNPROCESSABLE_ENTITY = 422,\n FAILED_DEPENDENCY = 424,\n PRECONDITION_REQUIRED = 428,\n TOO_MANY_REQUESTS = 429,\n INTERNAL_SERVER_ERROR = 500,\n NOT_IMPLEMENTED = 501,\n BAD_GATEWAY = 502,\n SERVICE_UNAVAILABLE = 503,\n GATEWAY_TIMEOUT = 504,\n HTTP_VERSION_NOT_SUPPORTED = 505,\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.default.js","sourceRoot":"","sources":["../../src/config/config.default.ts"],"names":[],"mappings":";;;AAEa,QAAA,OAAO,GAAmB;IACrC,KAAK,EAAE,YAAY;IACnB,WAAW,EAAE,2CAA2C;IACxD,OAAO,EAAE,OAAO;IAChB,WAAW,EAAE,aAAa;CAC3B,CAAC","sourcesContent":["import { SwaggerOptions } from '../interfaces';\n\nexport const swagger: SwaggerOptions = {\n title: 'My Project',\n description: 'This is a swagger-ui for midwayjs project',\n version: '1.0.0',\n swaggerPath: '/swagger-ui',\n};\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configuration.js","sourceRoot":"","sources":["../src/configuration.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAIwB;AACxB,mDAA4D;AAC5D,wBAAuD;AACvD,yDAAyD;AAUzD,IAAa,oBAAoB,GAAjC,MAAa,oBAAoB;IAI/B,KAAK,CAAC,OAAO,CAAC,SAA2B;QACvC,IAAI,CAAC,kBAAkB;aACpB,eAAe,CAAC,CAAC,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;aAClD,OAAO,CAAC,GAAG,CAAC,EAAE;YACb,GAAG,CAAC,aAAa,CAAC,oBAAiB,CAAC,CAAC;QACvC,CAAC,CAAC,CAAC;QAEL,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,QAAQ,CAAC,kBAAe,CAAC,CAAC;QAC3D,QAAQ,CAAC,OAAO,EAAE,CAAC;IACrB,CAAC;CACF,CAAA;AAZC;IADC,IAAA,kBAAM,GAAE;8BACW,+BAAwB;gEAAC;AAFlC,oBAAoB;IARhC,IAAA,yBAAa,EAAC;QACb,aAAa,EAAE;YACb;gBACE,OAAO,EAAE,aAAa;aACvB;SACF;QACD,SAAS,EAAE,SAAS;KACrB,CAAC;GACW,oBAAoB,CAchC;AAdY,oDAAoB","sourcesContent":["import {\n ILifeCycle,\n IMidwayContainer,\n MidwayApplicationManager,\n} from '@midwayjs/core';\nimport { Inject, Configuration } from '@midwayjs/decorator';\nimport { SwaggerExplorer, SwaggerMiddleware } from '.';\nimport * as DefaultConfig from './config/config.default';\n\n@Configuration({\n importConfigs: [\n {\n default: DefaultConfig,\n },\n ],\n namespace: 'swagger',\n})\nexport class SwaggerConfiguration implements ILifeCycle {\n @Inject()\n applicationManager: MidwayApplicationManager;\n\n async onReady(container: IMidwayContainer) {\n this.applicationManager\n .getApplications(['express', 'koa', 'egg', 'faas'])\n .forEach(app => {\n app.useMiddleware(SwaggerMiddleware);\n });\n\n const explorer = await container.getAsync(SwaggerExplorer);\n explorer.scanApp();\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,iBAAiB,GAAG,SAAS,CAAC;AAC9B,QAAA,UAAU,GAAG;IACxB,aAAa,EAAE,GAAG,yBAAiB,eAAe;IAClD,YAAY,EAAE,GAAG,yBAAiB,cAAc;IAChD,QAAQ,EAAE,GAAG,yBAAiB,aAAa;IAC3C,cAAc,EAAE,GAAG,yBAAiB,gBAAgB;IACpD,WAAW,EAAE,GAAG,yBAAiB,aAAa;IAC9C,oBAAoB,EAAE,GAAG,yBAAiB,qBAAqB;IAC/D,0BAA0B,EAAE,GAAG,yBAAiB,0BAA0B;IAC1E,YAAY,EAAE,GAAG,yBAAiB,cAAc;IAChD,oBAAoB,EAAE,GAAG,yBAAiB,qBAAqB;IAC/D,sBAAsB,EAAE,GAAG,yBAAiB,uBAAuB;IACnE,aAAa,EAAE,GAAG,yBAAiB,eAAe;CACnD,CAAC","sourcesContent":["export const DECORATORS_PREFIX = 'swagger';\nexport const DECORATORS = {\n API_OPERATION: `${DECORATORS_PREFIX}/apiOperation`,\n API_RESPONSE: `${DECORATORS_PREFIX}/apiResponse`,\n API_TAGS: `${DECORATORS_PREFIX}/apiUseTags`,\n API_PARAMETERS: `${DECORATORS_PREFIX}/apiParameters`,\n API_HEADERS: `${DECORATORS_PREFIX}/apiHeaders`,\n API_MODEL_PROPERTIES: `${DECORATORS_PREFIX}/apiModelProperties`,\n API_MODEL_PROPERTIES_ARRAY: `${DECORATORS_PREFIX}/apiModelPropertiesArray`,\n API_SECURITY: `${DECORATORS_PREFIX}/apiSecurity`,\n API_EXCLUDE_ENDPOINT: `${DECORATORS_PREFIX}/apiExcludeEndpoint`,\n API_EXCLUDE_CONTROLLER: `${DECORATORS_PREFIX}/apiExcludeController`,\n API_EXTENSION: `${DECORATORS_PREFIX}/apiExtension`,\n};\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-basic.decorator.js","sourceRoot":"","sources":["../../src/decorators/api-basic.decorator.ts"],"names":[],"mappings":";;;AAAA,qEAAuD;AAEvD,SAAgB,YAAY,CAAC,IAAI,GAAG,OAAO;IACzC,OAAO,IAAA,oCAAW,EAAC,IAAI,CAAC,CAAC;AAC3B,CAAC;AAFD,oCAEC","sourcesContent":["import { ApiSecurity } from './api-security.decorator';\n\nexport function ApiBasicAuth(name = 'basic') {\n return ApiSecurity(name);\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-bearer.decorator.js","sourceRoot":"","sources":["../../src/decorators/api-bearer.decorator.ts"],"names":[],"mappings":";;;AAAA,qEAAuD;AAEvD,SAAgB,aAAa,CAAC,IAAI,GAAG,QAAQ;IAC3C,OAAO,IAAA,oCAAW,EAAC,IAAI,CAAC,CAAC;AAC3B,CAAC;AAFD,sCAEC","sourcesContent":["import { ApiSecurity } from './api-security.decorator';\n\nexport function ApiBearerAuth(name = 'bearer') {\n return ApiSecurity(name);\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-body.decorator.js","sourceRoot":"","sources":["../../src/decorators/api-body.decorator.ts"],"names":[],"mappings":";;;AASA,qDAK8B;AAC9B,uCAAsE;AAItE,IAAY,eAMX;AAND,WAAY,eAAe;IACzB,uEAAoD,CAAA;IACpD,4CAAyB,CAAA;IACzB,oDAAiC,CAAA;IACjC,qDAAkC,CAAA;IAClC,2DAAwC,CAAA;AAC1C,CAAC,EANW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAM1B;AAiBD,MAAM,mBAAmB,GAAoB;IAC3C,IAAI,EAAE,MAAM;IACZ,QAAQ,EAAE,IAAI;CACf,CAAC;AAEF,SAAgB,OAAO,CAAC,OAAuB;IAC7C,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,IAAA,6BAAmB,EACxC,OAA2B,CAAC,IAAI,EAChC,OAA2B,CAAC,OAAO,CACrC,CAAC;IACF,MAAM,KAAK,GAA0C;QACnD,EAAE,EAAE,MAAM;QACV,GAAG,OAAO;QACV,IAAI;QACJ,OAAO;KACR,CAAC;IAEF,IAAI,IAAA,wBAAW,EAAC,OAAO,CAAC,EAAE;QACxB,IAAA,+BAAkB,EAAC,KAAK,EAAE,OAAO,CAAC,CAAC;KACpC;SAAM,IAAI,IAAA,0BAAa,EAAC,OAAO,CAAC,EAAE;QACjC,IAAA,0BAAa,EAAC,KAAK,EAAE,OAAO,CAAC,CAAC;KAC/B;IACD,OAAO,IAAA,8BAAoB,EAAC,KAAK,EAAE,mBAAmB,CAAC,CAAC;AAC1D,CAAC;AAlBD,0BAkBC","sourcesContent":["/* eslint-disable @typescript-eslint/ban-types */\nimport {\n ContentObject,\n ExamplesObject,\n ReferenceObject,\n RequestBodyObject,\n SchemaObject,\n SwaggerEnumType,\n} from '../interfaces';\nimport {\n addEnumArraySchema,\n addEnumSchema,\n isEnumArray,\n isEnumDefined,\n} from '../common/enum.utils';\nimport { createParamDecorator, getTypeIsArrayTuple } from './helpers';\n\ntype RequestBodyOptions = Omit<RequestBodyObject, 'content'>;\n\nexport enum BodyContentType {\n FormUrlEncoded = 'application/x-www-form-urlencoded',\n JSON = 'application/json',\n Multipart = 'multipart/form-data',\n MultipartMixed = 'multipart/mixed',\n OctetStream = 'application/octet-stream',\n}\n\ninterface ApiBodyMetadata extends RequestBodyOptions {\n type?: any;\n isArray?: boolean;\n enum?: SwaggerEnumType;\n content?: ContentObject;\n contentType?: BodyContentType;\n}\n\ninterface ApiBodySchemaHost extends RequestBodyOptions {\n schema: SchemaObject | ReferenceObject;\n examples?: ExamplesObject;\n}\n\nexport type ApiBodyOptions = ApiBodyMetadata | ApiBodySchemaHost;\n\nconst defaultBodyMetadata: ApiBodyMetadata = {\n type: String,\n required: true,\n};\n\nexport function ApiBody(options: ApiBodyOptions): MethodDecorator {\n const [type, isArray] = getTypeIsArrayTuple(\n (options as ApiBodyMetadata).type,\n (options as ApiBodyMetadata).isArray\n );\n const param: ApiBodyMetadata & Record<string, any> = {\n in: 'body',\n ...options,\n type,\n isArray,\n };\n\n if (isEnumArray(options)) {\n addEnumArraySchema(param, options);\n } else if (isEnumDefined(options)) {\n addEnumSchema(param, options);\n }\n return createParamDecorator(param, defaultBodyMetadata);\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-cookie.decorator.js","sourceRoot":"","sources":["../../src/decorators/api-cookie.decorator.ts"],"names":[],"mappings":";;;AAAA,qEAAuD;AAEvD,SAAgB,aAAa,CAAC,IAAI,GAAG,QAAQ;IAC3C,OAAO,IAAA,oCAAW,EAAC,IAAI,CAAC,CAAC;AAC3B,CAAC;AAFD,sCAEC","sourcesContent":["import { ApiSecurity } from './api-security.decorator';\n\nexport function ApiCookieAuth(name = 'cookie') {\n return ApiSecurity(name);\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-exclude-controller.decorator.js","sourceRoot":"","sources":["../../src/decorators/api-exclude-controller.decorator.ts"],"names":[],"mappings":";;;AAAA,mDAAkE;AAClE,4CAA0C;AAE1C,SAAgB,oBAAoB,CAAC,OAAO,GAAG,IAAI;IACjD,OAAO,IAAA,uCAA2B,EAChC,sBAAU,CAAC,sBAAsB,EACjC,CAAC,OAAO,CAAC,EACT,KAAK,CACN,CAAC;AACJ,CAAC;AAND,oDAMC","sourcesContent":["import { createCustomMethodDecorator } from '@midwayjs/decorator';\nimport { DECORATORS } from '../constants';\n\nexport function ApiExcludeController(disable = true): any {\n return createCustomMethodDecorator(\n DECORATORS.API_EXCLUDE_CONTROLLER,\n [disable],\n false\n );\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-exclude-endpoint.decorator.js","sourceRoot":"","sources":["../../src/decorators/api-exclude-endpoint.decorator.ts"],"names":[],"mappings":";;;AAAA,mDAAkE;AAClE,4CAA0C;AAE1C,SAAgB,kBAAkB,CAAC,OAAO,GAAG,IAAI;IAC/C,OAAO,IAAA,uCAA2B,EAChC,sBAAU,CAAC,oBAAoB,EAC/B;QACE,OAAO;KACR,EACD,KAAK,CACN,CAAC;AACJ,CAAC;AARD,gDAQC","sourcesContent":["import { createCustomMethodDecorator } from '@midwayjs/decorator';\nimport { DECORATORS } from '../constants';\n\nexport function ApiExcludeEndpoint(disable = true): MethodDecorator {\n return createCustomMethodDecorator(\n DECORATORS.API_EXCLUDE_ENDPOINT,\n {\n disable,\n },\n false\n );\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-extension.decorator.js","sourceRoot":"","sources":["../../src/decorators/api-extension.decorator.ts"],"names":[],"mappings":";;;AAAA,4CAA0C;AAC1C,uCAAiD;AAEjD,SAAgB,YAAY,CAAC,YAAoB,EAAE,mBAAwB;IACzE,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;QAClC,MAAM,IAAI,KAAK,CACb,uEAAuE,CACxE,CAAC;KACH;IAED,MAAM,eAAe,GAAG;QACtB,CAAC,YAAY,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAAC;KAChE,CAAC;IAEF,OAAO,IAAA,8BAAoB,EAAC,sBAAU,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC;AACzE,CAAC;AAZD,oCAYC","sourcesContent":["import { DECORATORS } from '../constants';\nimport { createMixedDecorator } from './helpers';\n\nexport function ApiExtension(extensionKey: string, extensionProperties: any) {\n if (!extensionKey.startsWith('x-')) {\n throw new Error(\n 'Extension key is not prefixed. Please ensure you prefix it with `x-`.'\n );\n }\n\n const extensionObject = {\n [extensionKey]: JSON.parse(JSON.stringify(extensionProperties)),\n };\n\n return createMixedDecorator(DECORATORS.API_EXTENSION, extensionObject);\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-header.decorator.js","sourceRoot":"","sources":["../../src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UAAyC,EACpC,EAAE;QACP,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC;IAC1E,CAAC,CAAC;AACJ,CAAC,CAAC;AAVW,QAAA,UAAU,cAUrB","sourcesContent":["import { DECORATORS } from '../constants';\nimport { SwaggerEnumType, ParameterObject, Type } from '../interfaces';\nimport { getEnumType, getEnumValues } from '../common/enum.utils';\nimport { createParamDecorator } from './helpers';\nimport { createCustomMethodDecorator } from '@midwayjs/decorator';\n\nexport interface ApiHeaderOptions extends Omit<ParameterObject, 'in'> {\n enum?: SwaggerEnumType;\n}\n\nconst defaultHeaderOptions: Partial<ApiHeaderOptions> = {\n name: '',\n};\n\nexport function ApiHeader(options: ApiHeaderOptions): any {\n const param = {\n name: !options.name ? defaultHeaderOptions.name : options.name,\n in: 'header',\n description: options.description,\n required: options.required,\n schema: {\n ...(options.schema || {}),\n type: 'string',\n },\n };\n\n if (options.enum) {\n const enumValues = getEnumValues(options.enum);\n param.schema = {\n enum: enumValues,\n type: getEnumType(enumValues),\n };\n }\n\n return (\n target: object | Type,\n key?: string | symbol,\n descriptor?: TypedPropertyDescriptor<any>\n ): any => {\n if (descriptor) {\n return createParamDecorator(param, defaultHeaderOptions as any)(\n target,\n key,\n descriptor\n );\n }\n return createCustomMethodDecorator(DECORATORS.API_HEADERS, param, false)(\n target,\n undefined,\n undefined\n );\n };\n}\n\nexport const ApiHeaders = (\n headers: ApiHeaderOptions[]\n): MethodDecorator & ClassDecorator => {\n return (\n target: object | Type,\n key?: string | symbol,\n descriptor?: TypedPropertyDescriptor<any>\n ): any => {\n headers.forEach(options => ApiHeader(options)(target, key, descriptor));\n };\n};\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-oauth2.decorator.js","sourceRoot":"","sources":["../../src/decorators/api-oauth2.decorator.ts"],"names":[],"mappings":";;;AAAA,qEAAuD;AAEvD,SAAgB,SAAS,CAAC,MAAgB,EAAE,IAAI,GAAG,QAAQ;IACzD,OAAO,IAAA,oCAAW,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AACnC,CAAC;AAFD,8BAEC","sourcesContent":["import { ApiSecurity } from './api-security.decorator';\n\nexport function ApiOAuth2(scopes: string[], name = 'oauth2') {\n return ApiSecurity(name, scopes);\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-operation.decorator.js","sourceRoot":"","sources":["../../src/decorators/api-operation.decorator.ts"],"names":[],"mappings":";;;AAAA,mDAAkE;AAClE,4CAA0C;AAK1C,MAAM,uBAAuB,GAAwB;IACnD,OAAO,EAAE,EAAE;CACZ,CAAC;AAEF,SAAgB,YAAY,CAAC,OAA4B;IACvD,OAAO,IAAA,uCAA2B,EAChC,sBAAU,CAAC,aAAa,EACxB;QACE,GAAG,uBAAuB;QAC1B,GAAG,OAAO;KACY,EACxB,KAAK,CACN,CAAC;AACJ,CAAC;AATD,oCASC","sourcesContent":["import { createCustomMethodDecorator } from '@midwayjs/decorator';\nimport { DECORATORS } from '../constants';\nimport { OperationObject } from '../interfaces';\n\nexport type ApiOperationOptions = Partial<OperationObject>;\n\nconst defaultOperationOptions: ApiOperationOptions = {\n summary: '',\n};\n\nexport function ApiOperation(options: ApiOperationOptions): MethodDecorator {\n return createCustomMethodDecorator(\n DECORATORS.API_OPERATION,\n {\n ...defaultOperationOptions,\n ...options,\n } as ApiOperationOptions,\n false\n );\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-param.decorator.js","sourceRoot":"","sources":["../../src/decorators/api-param.decorator.ts"],"names":[],"mappings":";;;AAMA,uCAAiD;AACjD,qDAAkE;AAiBlE,MAAM,mBAAmB,GAAoB;IAC3C,IAAI,EAAE,EAAE;IACR,QAAQ,EAAE,IAAI;CACf,CAAC;AAEF,SAAgB,QAAQ,CAAC,OAAwB;IAC/C,MAAM,KAAK,GAAwB;QACjC,IAAI,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI;QAC7D,EAAE,EAAE,MAAM;QACV,GAAG,OAAO;KACX,CAAC;IAEF,MAAM,gBAAgB,GAAG,OAA2B,CAAC;IACrD,IAAI,gBAAgB,CAAC,IAAI,EAAE;QACzB,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,IAAK,EAAmB,CAAC;QAEpD,MAAM,WAAW,GAAG,KAAK,CAAC,MAAsB,CAAC;QACjD,MAAM,UAAU,GAAG,IAAA,0BAAa,EAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;QACxD,WAAW,CAAC,IAAI,GAAG,IAAA,wBAAW,EAAC,UAAU,CAAC,CAAC;QAC3C,WAAW,CAAC,IAAI,GAAG,UAAU,CAAC;QAE9B,IAAI,gBAAgB,CAAC,QAAQ,EAAE;YAC7B,KAAK,CAAC,QAAQ,GAAG,gBAAgB,CAAC,QAAQ,CAAC;SAC5C;KACF;IAED,OAAO,IAAA,8BAAoB,EAAC,KAAK,EAAE,mBAAmB,CAAC,CAAC;AAC1D,CAAC;AAtBD,4BAsBC","sourcesContent":["import {\n Type,\n ParameterObject,\n SchemaObject,\n SwaggerEnumType,\n} from '../interfaces';\nimport { createParamDecorator } from './helpers';\nimport { getEnumValues, getEnumType } from '../common/enum.utils';\n\ntype ParameterOptions = Omit<ParameterObject, 'in' | 'schema'>;\n\ninterface ApiParamMetadata extends ParameterOptions {\n type?: Type | string;\n format?: string;\n enum?: SwaggerEnumType;\n enumName?: string;\n}\n\ninterface ApiParamSchemaHost extends ParameterOptions {\n schema: SchemaObject;\n}\n\nexport type ApiParamOptions = ApiParamMetadata | ApiParamSchemaHost;\n\nconst defaultParamOptions: ApiParamOptions = {\n name: '',\n required: true,\n};\n\nexport function ApiParam(options: ApiParamOptions): MethodDecorator {\n const param: Record<string, any> = {\n name: !options.name ? defaultParamOptions.name : options.name,\n in: 'path',\n ...options,\n };\n\n const apiParamMetadata = options as ApiParamMetadata;\n if (apiParamMetadata.enum) {\n param.schema = param.schema || ({} as SchemaObject);\n\n const paramSchema = param.schema as SchemaObject;\n const enumValues = getEnumValues(apiParamMetadata.enum);\n paramSchema.type = getEnumType(enumValues);\n paramSchema.enum = enumValues;\n\n if (apiParamMetadata.enumName) {\n param.enumName = apiParamMetadata.enumName;\n }\n }\n\n return createParamDecorator(param, defaultParamOptions);\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-property.decorator.js","sourceRoot":"","sources":["../../src/decorators/api-property.decorator.ts"],"names":[],"mappings":";;;AAAA,4CAA0C;AAE1C,qDAAkE;AAClE,uCAAyE;AASzE,MAAM,WAAW,GAAG,CAAC,GAAuB,EAAW,EAAE,CACvD,GAAG,CAAC,OAAO,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC;AAE5B,SAAgB,WAAW,CACzB,UAA8B,EAAE;IAEhC,OAAO,0BAA0B,CAAC,OAAO,CAAC,CAAC;AAC7C,CAAC;AAJD,kCAIC;AAED,SAAgB,0BAA0B,CACxC,UAA8B,EAAE;IAEhC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,IAAA,6BAAmB,EAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAC3E,OAAO,GAAG;QACR,GAAG,OAAO;QACV,IAAI;KACL,CAAC;IAEF,IAAI,WAAW,CAAC,OAAO,CAAC,EAAE;QACxB,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC;QAEvB,MAAM,UAAU,GAAG,IAAA,0BAAa,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC/C,OAAO,CAAC,KAAK,GAAG;YACd,IAAI,EAAE,IAAA,wBAAW,EAAC,UAAU,CAAC;YAC7B,IAAI,EAAE,UAAU;SACjB,CAAC;QACF,OAAO,OAAO,CAAC,IAAI,CAAC;KACrB;SAAM,IAAI,OAAO,CAAC,IAAI,EAAE;QACvB,MAAM,UAAU,GAAG,IAAA,0BAAa,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAE/C,OAAO,CAAC,IAAI,GAAG,UAAU,CAAC;QAC1B,OAAO,CAAC,IAAI,GAAG,IAAA,wBAAW,EAAC,UAAU,CAAC,CAAC;KACxC;IAED,IAAI,OAAO,EAAE;QACX,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC;QACvB,OAAO,CAAC,KAAK,GAAG;YACd,IAAI,EAAE,IAAW;SAClB,CAAC;KACH;IAED,OAAO,IAAA,iCAAuB,EAAC,sBAAU,CAAC,oBAAoB,EAAE,OAAO,CAAC,CAAC;AAC3E,CAAC;AAjCD,gEAiCC;AAED,SAAgB,mBAAmB,CACjC,UAA8B,EAAE;IAEhC,OAAO,WAAW,CAAC;QACjB,GAAG,OAAO;QACV,QAAQ,EAAE,KAAK;KAChB,CAAC,CAAC;AACL,CAAC;AAPD,kDAOC;AAED,SAAgB,mBAAmB,CACjC,UAGI,EAAE;IAEN,OAAO,WAAW,CAAC;QACjB,QAAQ,EAAE,IAAI;QACd,GAAG,OAAO;KACX,CAAC,CAAC;AACL,CAAC;AAVD,kDAUC","sourcesContent":["import { DECORATORS } from '../constants';\nimport { SchemaObjectMetadata } from '../interfaces';\nimport { getEnumType, getEnumValues } from '../common/enum.utils';\nimport { createPropertyDecorator, getTypeIsArrayTuple } from './helpers';\n\nexport interface ApiPropertyOptions\n extends Omit<SchemaObjectMetadata, 'name' | 'enum'> {\n name?: string;\n enum?: any[] | Record<string, any>;\n enumName?: string;\n}\n\nconst isEnumArray = (obj: ApiPropertyOptions): boolean =>\n obj.isArray && !!obj.enum;\n\nexport function ApiProperty(\n options: ApiPropertyOptions = {}\n): PropertyDecorator {\n return createApiPropertyDecorator(options);\n}\n\nexport function createApiPropertyDecorator(\n options: ApiPropertyOptions = {}\n): PropertyDecorator {\n const [type, isArray] = getTypeIsArrayTuple(options.type, options.isArray);\n options = {\n ...options,\n type,\n };\n\n if (isEnumArray(options)) {\n options.type = 'array';\n\n const enumValues = getEnumValues(options.enum);\n options.items = {\n type: getEnumType(enumValues),\n enum: enumValues,\n };\n delete options.enum;\n } else if (options.enum) {\n const enumValues = getEnumValues(options.enum);\n\n options.enum = enumValues;\n options.type = getEnumType(enumValues);\n }\n\n if (isArray) {\n options.type = 'array';\n options.items = {\n type: type as any,\n };\n }\n\n return createPropertyDecorator(DECORATORS.API_MODEL_PROPERTIES, options);\n}\n\nexport function ApiPropertyOptional(\n options: ApiPropertyOptions = {}\n): PropertyDecorator {\n return ApiProperty({\n ...options,\n required: false,\n });\n}\n\nexport function ApiResponseProperty(\n options: Pick<\n ApiPropertyOptions,\n 'type' | 'example' | 'format' | 'enum' | 'deprecated'\n > = {}\n): PropertyDecorator {\n return ApiProperty({\n readOnly: true,\n ...options,\n });\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-query.decorator.js","sourceRoot":"","sources":["../../src/decorators/api-query.decorator.ts"],"names":[],"mappings":";;;AAOA,qDAK8B;AAC9B,uCAAsE;AAmBtE,MAAM,mBAAmB,GAAoB;IAC3C,IAAI,EAAE,EAAE;IACR,QAAQ,EAAE,IAAI;CACf,CAAC;AAEF,SAAgB,QAAQ,CAAC,OAAwB;IAC/C,MAAM,gBAAgB,GAAG,OAA2B,CAAC;IACrD,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,IAAA,6BAAmB,EACzC,gBAAgB,CAAC,IAAI,EACrB,gBAAgB,CAAC,OAAO,CACzB,CAAC;IACF,MAAM,KAAK,GAAQ;QACjB,IAAI,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI;QAC7D,EAAE,EAAE,OAAO;QACX,GAAG,OAAO;QACV,IAAI;KACL,CAAC;IAEF,IAAI,IAAA,wBAAW,EAAC,OAAO,CAAC,EAAE;QACxB,IAAA,+BAAkB,EAAC,KAAK,EAAE,OAAO,CAAC,CAAC;KACpC;SAAM,IAAI,IAAA,0BAAa,EAAC,OAAO,CAAC,EAAE;QACjC,IAAA,0BAAa,EAAC,KAAK,EAAE,OAAO,CAAC,CAAC;KAC/B;IAED,IAAI,OAAO,EAAE;QACX,KAAK,CAAC,OAAO,GAAG,OAAO,CAAC;KACzB;IAED,OAAO,IAAA,8BAAoB,EAAC,KAAK,EAAE,mBAAmB,CAAC,CAAC;AAC1D,CAAC;AAxBD,4BAwBC","sourcesContent":["import {\n Type,\n ParameterObject,\n ReferenceObject,\n SchemaObject,\n SwaggerEnumType,\n} from '../interfaces';\nimport {\n addEnumSchema,\n addEnumArraySchema,\n isEnumArray,\n isEnumDefined,\n} from '../common/enum.utils';\nimport { createParamDecorator, getTypeIsArrayTuple } from './helpers';\n\ntype ParameterOptions = Omit<ParameterObject, 'in' | 'schema' | 'name'>;\n\ninterface ApiQueryMetadata extends ParameterOptions {\n name?: string;\n type?: Type | string;\n isArray?: boolean;\n enum?: SwaggerEnumType;\n enumName?: string;\n}\n\ninterface ApiQuerySchemaHost extends ParameterOptions {\n name?: string;\n schema: SchemaObject | ReferenceObject;\n}\n\nexport type ApiQueryOptions = ApiQueryMetadata | ApiQuerySchemaHost;\n\nconst defaultQueryOptions: ApiQueryOptions = {\n name: '',\n required: true,\n};\n\nexport function ApiQuery(options: ApiQueryOptions): MethodDecorator {\n const apiQueryMetadata = options as ApiQueryMetadata;\n const [type, isArray] = getTypeIsArrayTuple(\n apiQueryMetadata.type,\n apiQueryMetadata.isArray\n );\n const param: any = {\n name: !options.name ? defaultQueryOptions.name : options.name,\n in: 'query',\n ...options,\n type,\n };\n\n if (isEnumArray(options)) {\n addEnumArraySchema(param, options);\n } else if (isEnumDefined(options)) {\n addEnumSchema(param, options);\n }\n\n if (isArray) {\n param.isArray = isArray;\n }\n\n return createParamDecorator(param, defaultQueryOptions);\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-response.decorator.js","sourceRo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AA,8BAA8B,kCAMtC;AAEE,MAAM,+BAA+B,GAAG,CAC7C,UAA8B,EAAE,EAChC,EAAE,CACF,WAAW,CAAC;IACV,GAAG,OAAO;IACV,MAAM,EAAE,uBAAU,CAAC,sBAAsB;CAC1C,CAAC,CAAC;AANQ,QAAA,+BAA+B,mCAMvC;AAEE,MAAM,kBAAkB,GAAG,CAAC,UAA8B,EAAE,EAAE,EAAE,CACrE,WAAW,CAAC;IACV,GAAG,OAAO;IACV,MAAM,EAAE,SAAS;CAClB,CAAC,CAAC;AAJQ,QAAA,kBAAkB,sBAI1B","sourcesContent":["import { DECORATORS } from '../constants';\nimport {\n ResponseObject,\n SchemaObject,\n ReferenceObject,\n Type,\n} from '../interfaces';\nimport { getTypeIsArrayTuple } from './helpers';\nimport { HttpStatus } from '../common/httpStatus';\nimport { createCustomMethodDecorator } from '@midwayjs/decorator';\n\nexport interface ApiResponseMetadata\n extends Omit<ResponseObject, 'description'> {\n status?: number | 'default';\n type?: Type | string | Record<string, any>;\n isArray?: boolean;\n description?: string;\n}\n\nexport interface ApiResponseSchemaHost\n extends Omit<ResponseObject, 'description'> {\n schema: SchemaObject & Partial<ReferenceObject>;\n status?: number;\n description?: string;\n}\n\nexport type ApiResponseOptions = ApiResponseMetadata | ApiResponseSchemaHost;\n\nexport function ApiResponse(options: ApiResponseOptions): any {\n const [type, isArray] = getTypeIsArrayTuple(\n (options as ApiResponseMetadata).type,\n (options as ApiResponseMetadata).isArray\n );\n\n (options as ApiResponseMetadata).type = type;\n (options as ApiResponseMetadata).isArray = isArray;\n options.description = options.description ? options.description : '';\n\n const groupedMetadata = {\n [options.status || 'default']: options,\n };\n\n return createCustomMethodDecorator(\n DECORATORS.API_RESPONSE,\n groupedMetadata,\n false\n );\n}\n\nexport const ApiOkResponse = (options: ApiResponseOptions = {}) =>\n ApiResponse({\n ...options,\n status: HttpStatus.OK,\n });\n\nexport const ApiCreatedResponse = (options: ApiResponseOptions = {}) =>\n ApiResponse({\n ...options,\n status: HttpStatus.CREATED,\n });\n\nexport const ApiAcceptedResponse = (options: ApiResponseOptions = {}) =>\n ApiResponse({\n ...options,\n status: HttpStatus.ACCEPTED,\n });\n\nexport const ApiNoContentResponse = (options: ApiResponseOptions = {}) =>\n ApiResponse({\n ...options,\n status: HttpStatus.NO_CONTENT,\n });\n\nexport const ApiMovedPermanentlyResponse = (options: ApiResponseOptions = {}) =>\n ApiResponse({\n ...options,\n status: HttpStatus.MOVED_PERMANENTLY,\n });\n\nexport const ApiFoundResponse = (options: ApiResponseOptions = {}) =>\n ApiResponse({\n ...options,\n status: HttpStatus.FOUND,\n });\n\nexport const ApiBadRequestResponse = (options: ApiResponseOptions = {}) =>\n ApiResponse({\n ...options,\n status: HttpStatus.BAD_REQUEST,\n });\n\nexport const ApiUnauthorizedResponse = (options: ApiResponseOptions = {}) =>\n ApiResponse({\n ...options,\n status: HttpStatus.UNAUTHORIZED,\n });\n\nexport const ApiTooManyRequestsResponse = (options: ApiResponseOptions = {}) =>\n ApiResponse({\n ...options,\n status: HttpStatus.TOO_MANY_REQUESTS,\n });\n\nexport const ApiNotFoundResponse = (options: ApiResponseOptions = {}) =>\n ApiResponse({\n ...options,\n status: HttpStatus.NOT_FOUND,\n });\n\nexport const ApiInternalServerErrorResponse = (\n options: ApiResponseOptions = {}\n) =>\n ApiResponse({\n ...options,\n status: HttpStatus.INTERNAL_SERVER_ERROR,\n });\n\nexport const ApiBadGatewayResponse = (options: ApiResponseOptions = {}) =>\n ApiResponse({\n ...options,\n status: HttpStatus.BAD_GATEWAY,\n });\n\nexport const ApiConflictResponse = (options: ApiResponseOptions = {}) =>\n ApiResponse({\n ...options,\n status: HttpStatus.CONFLICT,\n });\n\nexport const ApiForbiddenResponse = (options: ApiResponseOptions = {}) =>\n ApiResponse({\n ...options,\n status: HttpStatus.FORBIDDEN,\n });\n\nexport const ApiGatewayTimeoutResponse = (options: ApiResponseOptions = {}) =>\n ApiResponse({\n ...options,\n status: HttpStatus.GATEWAY_TIMEOUT,\n });\n\nexport const ApiGoneResponse = (options: ApiResponseOptions = {}) =>\n ApiResponse({\n ...options,\n status: HttpStatus.GONE,\n });\n\nexport const ApiMethodNotAllowedResponse = (options: ApiResponseOptions = {}) =>\n ApiResponse({\n ...options,\n status: HttpStatus.METHOD_NOT_ALLOWED,\n });\n\nexport const ApiNotAcceptableResponse = (options: ApiResponseOptions = {}) =>\n ApiResponse({\n ...options,\n status: HttpStatus.NOT_ACCEPTABLE,\n });\n\nexport const ApiNotImplementedResponse = (options: ApiResponseOptions = {}) =>\n ApiResponse({\n ...options,\n status: HttpStatus.NOT_IMPLEMENTED,\n });\n\nexport const ApiPreconditionFailedResponse = (\n options: ApiResponseOptions = {}\n) =>\n ApiResponse({\n ...options,\n status: HttpStatus.PRECONDITION_FAILED,\n });\n\nexport const ApiPayloadTooLargeResponse = (options: ApiResponseOptions = {}) =>\n ApiResponse({\n ...options,\n status: HttpStatus.PAYLOAD_TOO_LARGE,\n });\n\nexport const ApiRequestTimeoutResponse = (options: ApiResponseOptions = {}) =>\n ApiResponse({\n ...options,\n status: HttpStatus.REQUEST_TIMEOUT,\n });\n\nexport const ApiServiceUnavailableResponse = (\n options: ApiResponseOptions = {}\n) =>\n ApiResponse({\n ...options,\n status: HttpStatus.SERVICE_UNAVAILABLE,\n });\n\nexport const ApiUnprocessableEntityResponse = (\n options: ApiResponseOptions = {}\n) =>\n ApiResponse({\n ...options,\n status: HttpStatus.UNPROCESSABLE_ENTITY,\n });\n\nexport const ApiUnsupportedMediaTypeResponse = (\n options: ApiResponseOptions = {}\n) =>\n ApiResponse({\n ...options,\n status: HttpStatus.UNSUPPORTED_MEDIA_TYPE,\n });\n\nexport const ApiDefaultResponse = (options: ApiResponseOptions = {}) =>\n ApiResponse({\n ...options,\n status: 'default',\n });\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-security.decorator.js","sourceRoot":"","sources":["../../src/decorators/api-security.decorator.ts"],"names":[],"mappings":";;;AAAA,mDAAkE;AAClE,4CAA0C;AAG1C,SAAgB,WAAW,CACzB,IAAwC,EACxC,eAAyB,EAAE;IAE3B,IAAI,QAAmC,CAAC;IAExC,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QAC5B,QAAQ,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,YAAY,IAAI,EAAE,EAAE,CAAC;KAC3C;SAAM;QACL,QAAQ,GAAG,IAAI,CAAC;KACjB;IAED,OAAO,IAAA,uCAA2B,EAAC,sBAAU,CAAC,YAAY,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;AAC/E,CAAC;AAbD,kCAaC","sourcesContent":["import { createCustomMethodDecorator } from '@midwayjs/decorator';\nimport { DECORATORS } from '../constants';\nimport { SecurityRequirementObject } from '../interfaces';\n\nexport function ApiSecurity(\n name: string | SecurityRequirementObject,\n requirements: string[] = []\n): any {\n let metadata: SecurityRequirementObject;\n\n if (typeof name === 'string') {\n metadata = { [name]: requirements || [] };\n } else {\n metadata = name;\n }\n\n return createCustomMethodDecorator(DECORATORS.API_SECURITY, metadata, false);\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-tags.decorator.js","sourceRoot":"","sources":["../../src/decorators/api-tags.decorator.ts"],"names":[],"mappings":";;;AAAA,4CAA0C;AAC1C,uCAAiD;AAEjD,SAAgB,OAAO,CAAC,GAAG,IAAc;IACvC,OAAO,IAAA,8BAAoB,EAAC,sBAAU,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;AACzD,CAAC;AAFD,0BAEC","sourcesContent":["import { DECORATORS } from '../constants';\nimport { createMixedDecorator } from './helpers';\n\nexport function ApiTags(...tags: string[]) {\n return createMixedDecorator(DECORATORS.API_TAGS, tags);\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/decorators/helpers.ts"],"names":[],"mappings":";;;AAAA,mDAG6B;AAC7B,4CAA0C;AAG1C,SAAgB,uBAAuB,CACrC,OAAe,EACf,QAAW;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ECORATORS } from '../constants';\nimport type { Type } from '../interfaces';\n\nexport function createPropertyDecorator<T extends Record<string, any> = any>(\n metakey: string,\n metadata: T\n): PropertyDecorator {\n return createCustomPropertyDecorator(metakey, metadata, false);\n}\n\nexport function createMixedDecorator<T = any>(\n metakey: string,\n metadata: T\n): any {\n return createCustomMethodDecorator(metakey, metadata, false);\n}\n\nexport function createParamDecorator<T extends Record<string, any> = any>(\n metadata: T,\n initial: Partial<T>\n): MethodDecorator {\n return createCustomMethodDecorator(\n DECORATORS.API_PARAMETERS,\n {\n ...initial,\n ...metadata,\n },\n false\n );\n}\n\nexport function getTypeIsArrayTuple(\n input: Type | undefined | string | Record<string, any>,\n isArrayFlag: boolean\n): [Type | undefined | string | Record<string, any>, boolean] {\n if (!input) {\n return [input as undefined, isArrayFlag];\n }\n if (isArrayFlag) {\n return [input as Type, isArrayFlag];\n }\n const isInputArray = Array.isArray(input);\n const type = isInputArray ? input[0] : input;\n return [type, isInputArray];\n}\n\nexport function getSchemaPath(clzz: Type | string) {\n let str = clzz;\n if (typeof clzz === 'object') {\n str = clzz ? (clzz as any).name : clzz;\n }\n return `#/components/schemas/${str}`;\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,uDAAqC;AACrC,mEAAiD;AACjD,qEAAmD;AACnD,yDAAuC;AACvC,4DAA0C;AAC1C,wDAAsC;AACtC,mEAKkC;AAJhC,qHAAA,WAAW,OAAA;AACX,6HAAA,mBAAmB,OAAA;AAEnB,6HAAA,mBAAmB,OAAA;AAErB,wDAAsC;AACtC,2DAAyC;AACzC,uDAAqC;AACrC,4DAA0C;AAC1C,wDAAsC;AACtC,yDAAuC;AACvC,yDAAuC;AACvC,yDAAuC;AACvC,2DAAyC;AACzC,qCAA0C;AAAjC,wGAAA,aAAa,OAAA","sourcesContent":["export * from './api-body.decorator';\nexport * from './api-exclude-endpoint.decorator';\nexport * from './api-exclude-controller.decorator';\nexport * from './api-header.decorator';\nexport * from './api-operation.decorator';\nexport * from './api-param.decorator';\nexport {\n ApiProperty,\n ApiPropertyOptional,\n ApiPropertyOptions,\n ApiResponseProperty,\n} from './api-property.decorator';\nexport * from './api-query.decorator';\nexport * from './api-response.decorator';\nexport * from './api-tags.decorator';\nexport * from './api-extension.decorator';\nexport * from './api-basic.decorator';\nexport * from './api-bearer.decorator';\nexport * from './api-cookie.decorator';\nexport * from './api-oauth2.decorator';\nexport * from './api-security.decorator';\nexport { getSchemaPath } from './helpers';\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documentBuilder.js","sourceRoot":"","sources":["../src/documentBuilder.ts"],"names":[],"mappings":";;;AAWA,MAAa,eAAe;IAA5B;QACmB,aAAQ,GAAkB;YACzC,OAAO,EAAE,OAAO;YAChB,IAAI,EAAE;gBACJ,KAAK,EAAE,EAAE;gBACT,WAAW,EAAE,EAAE;gBACf,OAAO,EAAE,OAAO;gBAChB,OAAO,EAAE,EAAE;aACZ;YACD,IAAI,EAAE,EAAE;YACR,OAAO,EAAE,EAAE;YACX,UAAU,EAAE,EAAE;YACd,KAAK,EAAE,EAAE;SACV,CAAC;IAmPJ,CAAC;IAjPQ,QAAQ,CAAC,KAAa;QAC3B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACjC,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,cAAc,CAAC,WAAmB;QACvC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC7C,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,UAAU,CAAC,OAAe;QAC/B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACrC,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,iBAAiB,CAAC,cAAsB;QAC7C,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,cAAc,GAA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,CAAC;YAClB,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC;YAElB,MAAM,GAAG,GAAG,EAAE,CAAC,MAAM,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC;YAC1D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;gBAC5B,IAAI,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE;oBACvC,OAAO,CAAC,CAAC;iBACV;qBAAM,IAAI,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE;oBAC9C,OAAO,CAAC,CAAC,CAAC;iBACX;aACF;YAED,OAAO,CAAC,CAAC;QACX,CAAC,CAAC,CAAC;IACL,CAAC;IAEM,KAAK;QACV,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF;AAhQD,0CAgQC","sourcesContent":["import {\n OpenAPIObject,\n ExternalDocumentationObject,\n SecurityRequirementObject,\n SecuritySchemeObject,\n ServerVariableObject,\n PathItemObject,\n SchemaObject,\n TagObject,\n} from './interfaces';\n\nexport class DocumentBuilder {\n private readonly document: OpenAPIObject = {\n openapi: '3.0.1',\n info: {\n title: '',\n description: '',\n version: '1.0.0',\n contact: {},\n },\n tags: [],\n servers: [],\n components: {},\n paths: {},\n };\n\n public setTitle(title: string): this {\n this.document.info.title = title;\n return this;\n }\n\n public setDescription(description: string): this {\n this.document.info.description = description;\n return this;\n }\n\n public setVersion(version: string): this {\n this.document.info.version = version;\n return this;\n }\n\n public setTermsOfService(termsOfService: string): this {\n this.document.info.termsOfService = termsOfService;\n return this;\n }\n\n public setContact(name: string, url: string, email: string): this {\n this.document.info.contact = { name, url, email };\n return this;\n }\n\n public setLicense(name: string, url: string): this {\n this.document.info.license = { name, url };\n return this;\n }\n\n public addServer(\n url: string,\n description?: string,\n variables?: Record<string, ServerVariableObject>\n ): this {\n this.document.servers.push({ url, description, variables });\n return this;\n }\n\n public setExternalDoc(description: string, url: string): this {\n this.document.externalDocs = { description, url };\n return this;\n }\n\n public setBasePath(path: string | string[]) {\n if ((this.document as any).basePath) {\n if (Array.isArray((this.document as any).basePath)) {\n (this.document as any).basePath.push(path);\n } else {\n (this.document as any).basePath = [\n (this.document as any).basePath,\n path,\n ];\n }\n } else {\n (this.document as any).basePath = path;\n }\n return this;\n }\n\n public addPaths(paths: Record<string, PathItemObject>) {\n Object.assign(this.document.paths, paths);\n return this;\n }\n\n public addSchema(schema: Record<string, SchemaObject>) {\n if (!this.document.components.schemas) {\n this.document.components.schemas = {};\n }\n Object.assign(this.document.components.schemas, schema);\n return this;\n }\n\n public getSchema(name: string): SchemaObject {\n if (this.document.components?.schemas) {\n return this.document.components?.schemas[name] as SchemaObject;\n }\n return undefined;\n }\n\n public addTag(\n name: string,\n description = '',\n externalDocs?: ExternalDocumentationObject\n ): this {\n if (Array.isArray(name)) {\n const arr = name as Array<string>;\n for (const s of arr) {\n this.document.tags.push({\n name: s,\n description: '',\n });\n }\n return this;\n }\n this.document.tags.push({\n name,\n description,\n externalDocs,\n });\n return this;\n }\n\n public addSecurity(name: string, options: SecuritySchemeObject): this {\n this.document.components.securitySchemes = {\n ...(this.document.components.securitySchemes || {}),\n [name]: options,\n };\n return this;\n }\n\n public addSecurityRequirements(\n name: string | SecurityRequirementObject,\n requirements: string[] = []\n ): this {\n let securityRequirement: SecurityRequirementObject;\n\n if (typeof name === 'string') {\n securityRequirement = { [name as string]: requirements };\n } else {\n securityRequirement = name as SecurityRequirementObject;\n }\n\n this.document.security = (this.document.security || []).concat({\n ...securityRequirement,\n });\n return this;\n }\n\n public addBearerAuth(\n options: SecuritySchemeObject = {\n type: 'http',\n },\n name = 'bearer'\n ): this {\n this.addSecurity(name, {\n type: 'http',\n scheme: 'bearer',\n bearerFormat: 'JWT',\n ...options,\n });\n return this;\n }\n\n public addOAuth2(\n options: SecuritySchemeObject = {\n type: 'oauth2',\n },\n name = 'oauth2'\n ): this {\n if (!name) {\n name = 'oauth2';\n }\n this.addSecurity(name, {\n type: 'oauth2',\n flows: {\n ...options?.flows,\n },\n });\n return this;\n }\n\n public addApiKey(\n options: SecuritySchemeObject = {\n type: 'apiKey',\n },\n name = 'api_key'\n ): this {\n if (!name) {\n name = 'api_key';\n }\n this.addSecurity(name, {\n type: 'apiKey',\n in: 'header',\n name,\n ...options,\n });\n return this;\n }\n\n public addBasicAuth(\n options: SecuritySchemeObject = {\n type: 'http',\n },\n name = 'basic'\n ): this {\n if (!name) {\n name = 'basic';\n }\n this.addSecurity(name, {\n type: 'http',\n scheme: 'basic',\n ...options,\n });\n return this;\n }\n\n public addCookieAuth(\n cookieName = 'connect.sid',\n options: SecuritySchemeObject = {\n type: 'apiKey',\n },\n securityName = 'cookie'\n ): this {\n if (!cookieName) {\n cookieName = 'connect.sid';\n }\n if (!securityName) {\n securityName = 'cookie';\n }\n this.addSecurity(securityName, {\n type: 'apiKey',\n in: 'cookie',\n name: cookieName,\n ...options,\n });\n return this;\n }\n\n public sortTags(): void {\n const tags = this.document.tags;\n this.document.tags = tags.sort((a: TagObject, b: TagObject): number => {\n const s1 = a.name;\n const s2 = b.name;\n\n const len = s1.length > s2.length ? s2.length : s1.length;\n for (let i = 0; i < len; i++) {\n if (s1.charCodeAt(i) > s2.charCodeAt(i)) {\n return 1;\n } else if (s1.charCodeAt(i) < s2.charCodeAt(i)) {\n return -1;\n }\n }\n\n return 0;\n });\n }\n\n public build(): Omit<OpenAPIObject, 'paths'> {\n return this.document;\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,+CAA6B;AAC7B,iDAAwE;AAA/D,8GAAA,oBAAoB,OAAiB;AAC9C,qDAAoD;AAA3C,kHAAA,eAAe,OAAA;AACxB,yDAAwD;AAA/C,sHAAA,iBAAiB,OAAA","sourcesContent":["export * from './decorators';\nexport * from './interfaces';\nexport { SwaggerConfiguration as Configuration } from './configuration';\nexport { SwaggerExplorer } from './swaggerExplorer';\nexport { SwaggerMiddleware } from './swaggerMiddleware';\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * inspired by https://github.com/metadevpro/openapi3-ts\n * @see https://github.com/OAI/OpenAPI-Specification/blob/3.0.0-rc0/versions/3.0.md\n */\n\nexport interface OpenAPIObject {\n openapi: string;\n info: InfoObject;\n servers?: ServerObject[];\n paths: PathsObject;\n components?: ComponentsObject;\n security?: SecurityRequirementObject[];\n tags?: TagObject[];\n externalDocs?: ExternalDocumentationObject;\n}\n\nexport interface InfoObject {\n title: string;\n description?: string;\n termsOfService?: string;\n contact?: ContactObject;\n license?: LicenseObject;\n version: string;\n}\n\nexport interface ContactObject {\n name?: string;\n url?: string;\n email?: string;\n}\n\nexport interface LicenseObject {\n name: string;\n url?: string;\n}\n\nexport interface ServerObject {\n url: string;\n description?: string;\n variables?: Record<string, ServerVariableObject>;\n}\n\nexport interface ServerVariableObject {\n enum?: string[] | boolean[] | number[];\n default: string | boolean | number;\n description?: string;\n}\n\nexport interface ComponentsObject {\n schemas?: Record<string, SchemaObject | ReferenceObject>;\n responses?: Record<string, ResponseObject | ReferenceObject>;\n parameters?: Record<string, ParameterObject | ReferenceObject>;\n examples?: Record<string, ExampleObject | ReferenceObject>;\n requestBodies?: Record<string, RequestBodyObject | ReferenceObject>;\n headers?: Record<string, HeaderObject | ReferenceObject>;\n securitySchemes?: Record<string, SecuritySchemeObject | ReferenceObject>;\n links?: Record<string, LinkObject | ReferenceObject>;\n callbacks?: Record<string, CallbackObject | ReferenceObject>;\n}\n\nexport type PathsObject = Record<string, PathItemObject>;\nexport interface PathItemObject {\n $ref?: string;\n summary?: string;\n description?: string;\n get?: OperationObject;\n put?: OperationObject;\n post?: OperationObject;\n delete?: OperationObject;\n options?: OperationObject;\n head?: OperationObject;\n patch?: OperationObject;\n trace?: OperationObject;\n servers?: ServerObject[];\n parameters?: (ParameterObject | ReferenceObject)[];\n}\n\nexport interface OperationObject {\n tags?: string[];\n summary?: string;\n description?: string;\n externalDocs?: ExternalDocumentationObject;\n operationId?: string;\n parameters?: (ParameterObject | ReferenceObject)[];\n requestBody?: RequestBodyObject | ReferenceObject;\n responses: ResponsesObject;\n callbacks?: CallbacksObject;\n deprecated?: boolean;\n security?: SecurityRequirementObject[];\n servers?: ServerObject[];\n}\n\nexport interface ExternalDocumentationObject {\n description?: string;\n url: string;\n}\n\nexport type ParameterLocation = 'query' | 'header' | 'path' | 'cookie';\nexport type ParameterStyle =\n | 'matrix'\n | 'label'\n | 'form'\n | 'simple'\n | 'spaceDelimited'\n | 'pipeDelimited'\n | 'deepObject';\n\nexport interface BaseParameterObject {\n description?: string;\n required?: boolean;\n deprecated?: boolean;\n allowEmptyValue?: boolean;\n style?: ParameterStyle;\n explode?: boolean;\n allowReserved?: boolean;\n schema?: SchemaObject | ReferenceObject;\n examples?: Record<string, ExampleObject | ReferenceObject>;\n example?: any;\n content?: ContentObject;\n}\n\nexport interface ParameterObject extends BaseParameterObject {\n name: string;\n in: ParameterLocation;\n}\n\nexport interface RequestBodyObject {\n description?: string;\n content: ContentObject;\n required?: boolean;\n}\n\nexport type ContentObject = Record<string, MediaTypeObject>;\nexport interface MediaTypeObject {\n schema?: SchemaObject | ReferenceObject;\n examples?: ExamplesObject;\n example?: any;\n encoding?: EncodingObject;\n}\n\nexport type EncodingObject = Record<string, EncodingPropertyObject>;\nexport interface EncodingPropertyObject {\n contentType?: string;\n headers?: Record<string, HeaderObject | ReferenceObject>;\n style?: string;\n explode?: boolean;\n allowReserved?: boolean;\n}\n\nexport interface ResponsesObject\n extends Record<string, ResponseObject | ReferenceObject | undefined> {\n default?: ResponseObject | ReferenceObject;\n}\n\nexport interface ResponseObject {\n description: string;\n headers?: HeadersObject;\n content?: ContentObject;\n links?: LinksObject;\n}\n\nexport type CallbacksObject = Record<string, CallbackObject | ReferenceObject>;\nexport type CallbackObject = Record<string, PathItemObject>;\nexport type HeadersObject = Record<string, HeaderObject | ReferenceObject>;\n\nexport interface ExampleObject {\n summary?: string;\n description?: string;\n value?: any;\n externalValue?: string;\n}\n\nexport type LinksObject = Record<string, LinkObject | ReferenceObject>;\nexport interface LinkObject {\n operationRef?: string;\n operationId?: string;\n parameters?: LinkParametersObject;\n requestBody?: any | string;\n description?: string;\n server?: ServerObject;\n}\n\nexport type LinkParametersObject = Record<string, any>;\nexport type HeaderObject = BaseParameterObject;\nexport interface TagObject {\n name: string;\n description?: string;\n externalDocs?: ExternalDocumentationObject;\n}\n\nexport type ExamplesObject = Record<string, ExampleObject | ReferenceObject>;\n\nexport interface ReferenceObject {\n $ref: string;\n}\n\nexport interface SchemaObject {\n nullable?: boolean;\n discriminator?: DiscriminatorObject;\n readOnly?: boolean;\n writeOnly?: boolean;\n xml?: XmlObject;\n externalDocs?: ExternalDocumentationObject;\n example?: any;\n examples?: any[] | Record<string, any>;\n deprecated?: boolean;\n type?: string;\n allOf?: (SchemaObject | ReferenceObject)[];\n oneOf?: (SchemaObject | ReferenceObject)[];\n anyOf?: (SchemaObject | ReferenceObject)[];\n not?: SchemaObject | ReferenceObject;\n items?: SchemaObject | ReferenceObject;\n properties?: Record<string, SchemaObject | ReferenceObject>;\n additionalProperties?: SchemaObject | ReferenceObject | boolean;\n patternProperties?: SchemaObject | ReferenceObject | any;\n description?: string;\n format?: string;\n default?: any;\n title?: string;\n multipleOf?: number;\n maximum?: number;\n exclusiveMaximum?: boolean;\n minimum?: number;\n exclusiveMinimum?: boolean;\n maxLength?: number;\n minLength?: number;\n pattern?: string;\n maxItems?: number;\n minItems?: number;\n uniqueItems?: boolean;\n maxProperties?: number;\n minProperties?: number;\n required?: string[];\n enum?: any[];\n}\n\nexport type SchemasObject = Record<string, SchemaObject>;\n\nexport interface DiscriminatorObject {\n propertyName: string;\n mapping?: Record<string, string>;\n}\n\nexport interface XmlObject {\n name?: string;\n namespace?: string;\n prefix?: string;\n attribute?: boolean;\n wrapped?: boolean;\n}\n\nexport type SecuritySchemeType = 'apiKey' | 'http' | 'oauth2' | 'openIdConnect';\n\nexport interface SecuritySchemeObject {\n type: SecuritySchemeType;\n description?: string;\n name?: string;\n in?: string;\n scheme?: string;\n bearerFormat?: string;\n flows?: OAuthFlowsObject;\n openIdConnectUrl?: string;\n}\n\nexport interface OAuthFlowsObject {\n implicit?: OAuthFlowObject;\n password?: OAuthFlowObject;\n clientCredentials?: OAuthFlowObject;\n authorizationCode?: OAuthFlowObject;\n}\n\nexport interface OAuthFlowObject {\n authorizationUrl?: string;\n tokenUrl?: string;\n refreshUrl?: string;\n scopes: ScopesObject;\n}\n\nexport type ScopesObject = Record<string, any>;\nexport type SecurityRequirementObject = Record<string, string[]>;\n\n/**\n * 非 open api spec\n */\nexport type SwaggerEnumType =\n | string[]\n | number[]\n | (string | number)[]\n | Record<number, string>;\n\nexport interface Type<T = any> extends Function {\n new (...args: any[]): T;\n}\n\nexport interface SchemaObjectMetadata\n extends Omit<SchemaObject, 'type' | 'required'> {\n type?: Type<unknown> | [Type] | string | Record<string, any>;\n isArray?: boolean;\n required?: boolean;\n name?: string;\n enumName?: string;\n}\n\nexport type AuthType =\n | 'basic'\n | 'bearer'\n | 'cookie'\n | 'oauth2'\n | 'apikey'\n | 'custom';\n\n/**\n * 继承自 https://swagger.io/specification/#security-scheme-object\n */\nexport interface AuthOptions extends Omit<SecuritySchemeObject, 'type'> {\n /**\n * 验权类型\n * basic => http basic 验证\n * bearer => http jwt 验证\n * cookie => cookie 方式验证\n * oauth2 => 使用 oauth2\n * apikey => apiKey\n * custom => 自定义方式\n */\n authType: AuthType;\n /**\n * https://swagger.io/specification/#security-scheme-object type 字段\n */\n type?: SecuritySchemeType;\n /**\n * authType = cookie 时可以修改,通过 ApiCookie 装饰器关联的名称\n */\n securityName?: string;\n /**\n * authType = cookie 时可以修改,cookie 的名称\n */\n cookieName?: string;\n}\n/**\n * see https://swagger.io/specification/\n */\nexport interface SwaggerOptions {\n /**\n * 默认值: My Project\n * https://swagger.io/specification/#info-object title 字段\n */\n title?: string;\n /**\n * 默认值: This is a swagger-ui for midwayjs project\n * https://swagger.io/specification/#info-object description 字段\n */\n description?: string;\n /**\n * 默认值: 1.0.0\n * https://swagger.io/specification/#info-object version 字段\n */\n version?: string;\n /**\n * https://swagger.io/specification/#info-object contact 字段\n */\n contact?: ContactObject;\n /**\n * https://swagger.io/specification/#info-object license 字段\n */\n license?: LicenseObject;\n /**\n * https://swagger.io/specification/#info-object termsOfService 字段\n */\n termsOfService?: string;\n /**\n * https://swagger.io/specification/#openapi-object externalDocs 字段\n */\n externalDocs?: ExternalDocumentationObject;\n /**\n * https://swagger.io/specification/#openapi-object servers 字段\n */\n servers?: Array<ServerObject>;\n /**\n * https://swagger.io/specification/#openapi-object tags 字段\n */\n tags?: Array<TagObject>;\n /**\n * 可以参考 https://swagger.io/specification/#security-scheme-object\n */\n auth?: AuthOptions | AuthOptions[];\n /**\n * api 的 根路径\n */\n basePath?: string | string[];\n /**\n * 默认值: /swagger-ui\n * 访问 swagger ui 的路径\n */\n swaggerPath?: string;\n /**\n * 对路由 tag 进行 ascii 排序\n * 可以使用 1-xxx、2-xxx、3-xxx 来定义 tag\n */\n tagSortable?: boolean;\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"swaggerExplorer.js","sourceRoot":"","sources":["../src/swaggerExplorer.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAoB6B;AAE7B,2CAAyC;AACzC,uDAAoD;AAMpD,wBAAoC;AAIpC,IAAa,eAAe,GAA5B,MAAa,eAAe;IAA5B;QAIU,oBAAe,GAAG,IAAI,iCAAe,EAAE,CAAC;IA8q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,CAAC,WAAW,CAAC;QACjC,KAAK,2BAAe,CAAC,UAAU;YAC7B,OAAO,MAAM,CAAC;QAChB;YACE,OAAO,QAAQ,CAAC;KACnB;AACH,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAK;IAC9B,QAAQ,KAAK,EAAE;QACb,KAAK,QAAQ;YACX,OAAO,QAAQ,CAAC;QAClB,KAAK,SAAS;YACZ,OAAO,SAAS,CAAC;QACnB,KAAK,QAAQ;YACX,OAAO,QAAQ,CAAC;QAClB,KAAK,QAAQ;YACX,OAAO,QAAQ,CAAC;QAClB;YACE,OAAO,KAAK,CAAC;KAChB;AACH,CAAC","sourcesContent":["import {\n Config,\n CONTROLLER_KEY,\n listModule,\n Provide,\n ControllerOption,\n getClassMetadata,\n getMethodParamTypes,\n Types,\n RouteParamTypes,\n RouterOption,\n WEB_ROUTER_KEY,\n WEB_ROUTER_PARAM_KEY,\n Init,\n Scope,\n ScopeEnum,\n INJECT_CUSTOM_PROPERTY,\n INJECT_CUSTOM_PARAM,\n INJECT_CUSTOM_METHOD,\n getPropertyType,\n} from '@midwayjs/decorator';\nimport { PathItemObject, Type } from './interfaces';\nimport { DECORATORS } from './constants';\nimport { DocumentBuilder } from './documentBuilder';\nimport {\n SwaggerOptions,\n AuthOptions,\n SecuritySchemeObject,\n} from './interfaces/';\nimport { BodyContentType } from '.';\n\n@Provide()\n@Scope(ScopeEnum.Singleton)\nexport class SwaggerExplorer {\n @Config('swagger')\n private swaggerConfig: SwaggerOptions;\n\n private documentBuilder = new DocumentBuilder();\n\n @Init()\n async init() {\n this.documentBuilder.setTitle(this.swaggerConfig.title);\n this.documentBuilder.setVersion(this.swaggerConfig.version);\n this.documentBuilder.setDescription(this.swaggerConfig.description);\n if (\n this.swaggerConfig?.contact &&\n typeof this.swaggerConfig?.contact === 'object'\n ) {\n this.documentBuilder.setContact(\n this.swaggerConfig?.contact?.name,\n this.swaggerConfig?.contact?.url,\n this.swaggerConfig?.contact?.email\n );\n }\n if (\n this.swaggerConfig?.license &&\n typeof this.swaggerConfig?.license === 'object'\n ) {\n this.documentBuilder.setLicense(\n this.swaggerConfig?.license?.name,\n this.swaggerConfig?.license?.url\n );\n }\n if (this.swaggerConfig.basePath) {\n this.documentBuilder.setBasePath(this.swaggerConfig.basePath);\n }\n if (this.swaggerConfig.termsOfService) {\n this.documentBuilder.setTermsOfService(this.swaggerConfig.termsOfService);\n }\n if (\n this.swaggerConfig?.externalDocs &&\n typeof this.swaggerConfig?.externalDocs === 'object'\n ) {\n this.documentBuilder.setExternalDoc(\n this.swaggerConfig?.externalDocs?.description,\n this.swaggerConfig?.externalDocs?.url\n );\n }\n if (\n this.swaggerConfig?.servers &&\n Array.isArray(this.swaggerConfig?.servers)\n ) {\n for (const serv of this.swaggerConfig?.servers) {\n this.documentBuilder.addServer(serv?.url, serv?.description);\n }\n }\n if (this.swaggerConfig?.tags && Array.isArray(this.swaggerConfig?.tags)) {\n for (const t of this.swaggerConfig?.tags) {\n this.documentBuilder.addTag(t.name, t.description, t.externalDocs);\n }\n }\n // 设置 auth 类型\n if (Array.isArray(this.swaggerConfig?.auth)) {\n for (const a of this.swaggerConfig?.auth) {\n this.setAuth(a);\n }\n } else {\n this.setAuth(this.swaggerConfig?.auth);\n }\n }\n\n public scanApp() {\n const routes = listModule(CONTROLLER_KEY);\n\n for (const route of routes) {\n this.generatePath(route);\n }\n\n if (this.swaggerConfig?.tagSortable) {\n this.documentBuilder.sortTags();\n }\n }\n\n public getData() {\n return this.documentBuilder.build();\n }\n\n private generatePath(target: Type) {\n const metaForMethods: any[] =\n getClassMetadata(INJECT_CUSTOM_METHOD, target) || [];\n const exs = metaForMethods.filter(\n item => item.key === DECORATORS.API_EXCLUDE_CONTROLLER\n );\n if (exs[0]) {\n return;\n }\n\n const metaForParams: any[] =\n getClassMetadata(INJECT_CUSTOM_PARAM, target) || [];\n\n const controllerOption: ControllerOption = getClassMetadata(\n CONTROLLER_KEY,\n target\n );\n\n const prefix = controllerOption.prefix;\n const tags = metaForMethods.filter(\n item => item.key === DECORATORS.API_TAGS\n );\n let strTags: string[] = [];\n if (tags.length > 0) {\n for (const t of tags) {\n // 这里 metadata => string[]\n strTags = strTags.concat(t.metadata);\n this.documentBuilder.addTag(t.metadata);\n }\n } else {\n const tag = { name: '', description: '' };\n if (prefix !== '/') {\n tag.name =\n controllerOption?.routerOptions.tagName ||\n (/^\\//.test(prefix) ? prefix.split('/')[1] : prefix);\n tag.description =\n controllerOption?.routerOptions.description || tag.name;\n } else {\n tag.name = controllerOption?.routerOptions.tagName;\n tag.description =\n controllerOption?.routerOptions.description || tag.name;\n }\n if (tag.name) {\n strTags.push(tag.name);\n this.documentBuilder.addTag(tag.name, tag.description);\n }\n }\n\n // const globalMiddleware = controllerOption.routerOptions.middleware;\n // get router info\n const webRouterInfo: RouterOption[] = getClassMetadata(\n WEB_ROUTER_KEY,\n target\n );\n\n let header = null;\n const headers = metaForMethods.filter(\n item => item.key === DECORATORS.API_HEADERS\n );\n if (headers.length > 0) {\n header = headers[0].metadata;\n }\n\n const security = metaForMethods.filter(\n item => item.key === DECORATORS.API_SECURITY\n );\n\n const paths: Record<string, PathItemObject> = {};\n if (webRouterInfo && typeof webRouterInfo[Symbol.iterator] === 'function') {\n for (const webRouter of webRouterInfo) {\n let url = (prefix + webRouter.path).replace('//', '/');\n url = replaceUrl(url, parseParamsInPath(url));\n\n // 判断是否忽略当前路由\n const endpoints = metaForMethods.filter(\n item =>\n item.key === DECORATORS.API_EXCLUDE_ENDPOINT &&\n item.propertyName === webRouter.method\n );\n if (endpoints[0]) {\n continue;\n }\n\n this.generateRouteMethod(\n url,\n webRouter,\n paths,\n metaForMethods,\n metaForParams,\n header,\n target\n );\n\n // 这里赋值 tags\n if (paths[url][webRouter.requestMethod].tags.length === 0) {\n paths[url][webRouter.requestMethod].tags = strTags;\n }\n // extension => prefix 为 x-\n const exts = metaForMethods.filter(\n item =>\n item.key === DECORATORS.API_EXTENSION &&\n item.propertyName === webRouter.method\n );\n for (const e of exts) {\n if (e.metadata) {\n Object.assign(paths[url][webRouter.requestMethod], e.metadata);\n }\n }\n\n if (security.length > 0) {\n if (!paths[url][webRouter.requestMethod].security) {\n paths[url][webRouter.requestMethod].security = [];\n }\n\n for (const s of security) {\n if (!s.metadata) {\n continue;\n }\n paths[url][webRouter.requestMethod].security.push(s.metadata);\n }\n }\n }\n }\n\n this.documentBuilder.addPaths(paths);\n }\n /**\n * 构造 router 提取方法\n */\n private generateRouteMethod(\n url: string,\n webRouter: RouterOption,\n paths: Record<string, PathItemObject>,\n metaForMethods: any[],\n metaForParams: any[],\n header: any,\n target: Type\n ) {\n const operMeta = metaForMethods.filter(\n item =>\n item.key === DECORATORS.API_OPERATION &&\n item.propertyName === webRouter.method\n )[0];\n\n let opts: PathItemObject = paths[url];\n if (!opts) {\n opts = {};\n }\n const parameters = [];\n opts[webRouter.requestMethod] = {\n summary: operMeta?.metadata?.summary,\n description: operMeta?.metadata?.description,\n operationId: operMeta?.metadata?.operationId || webRouter.method,\n tags: operMeta?.metadata?.tags || [],\n };\n /**\n * [{\"key\":\"web:router_param\",\"parameterIndex\":1,\"propertyName\":\"create\",\"metadata\":{\"type\":2}},\n * {\"key\":\"web:router_param\",\"parameterIndex\":0,\"propertyName\":\"create\",\"metadata\":{\"type\":1,\"propertyData\":\"createCatDto\"}}]\n */\n const routerArgs = metaForParams[webRouter.method] || [];\n // WEB_ROUTER_PARAM_KEY\n let args: any[] = routerArgs.filter(\n item => item.key === WEB_ROUTER_PARAM_KEY\n );\n args = args.filter(item => (item as any).key === WEB_ROUTER_PARAM_KEY);\n const types = getMethodParamTypes(target, webRouter.method);\n const params = metaForMethods.filter(\n item =>\n item.key === DECORATORS.API_PARAMETERS &&\n item.propertyName === webRouter.method\n );\n\n for (const arg of args) {\n const currentType = types[arg.parameterIndex];\n const p: any = {\n name: arg?.metadata?.propertyData ?? '',\n in: convertTypeToString(arg.metadata?.type),\n required: false,\n };\n\n if (p.in === 'path') {\n p.required = true;\n\n if (url.indexOf('{' + p.name + '}') === -1) {\n continue;\n }\n }\n\n if (Types.isClass(currentType)) {\n this.parseClzz(currentType);\n\n p.schema = {\n $ref: '#/components/schemas/' + currentType.name,\n };\n } else {\n p.schema = {\n type: convertSchemaType(currentType?.name ?? currentType),\n };\n }\n\n this.parseFromParamsToP(\n params[params.length - 1 - arg.parameterIndex],\n p\n );\n\n if (p.in === 'body') {\n // 这里兼容一下 @File()、@Files()、@Fields() 装饰器\n if (arg.metadata?.type === RouteParamTypes.FILESSTREAM) {\n p.schema = {\n type: 'object',\n properties: {\n files: {\n type: 'array',\n items: {\n type: 'string',\n format: 'binary',\n },\n description: p.description,\n },\n },\n };\n p.contentType = BodyContentType.Multipart;\n }\n if (arg.metadata?.type === RouteParamTypes.FILESTREAM) {\n p.schema = {\n type: 'object',\n properties: {\n file: {\n type: 'string',\n format: 'binary',\n description: p.description,\n },\n },\n };\n p.contentType = BodyContentType.Multipart;\n }\n if (arg.metadata?.type === RouteParamTypes.FIELDS) {\n if (p.schema['$ref']) {\n // 展开各个字段属性\n const name = p.schema['$ref'].replace('#/components/schemas/', '');\n const schema = this.documentBuilder.getSchema(name);\n delete p.schema['$ref'];\n p.schema = JSON.parse(JSON.stringify(schema));\n }\n p.contentType = BodyContentType.Multipart;\n }\n\n if (!p.content) {\n p.content = {};\n p.content[p.contentType || 'application/json'] = {\n schema: p.schema,\n };\n }\n if (!opts[webRouter.requestMethod].requestBody) {\n const requestBody = {\n required: true,\n description: p.description || p.name,\n content: p.content,\n };\n opts[webRouter.requestMethod].requestBody = requestBody;\n } else {\n // 这里拼 schema properties 时肯定存在\n Object.assign(\n opts[webRouter.requestMethod].requestBody.content[p.contentType]\n .schema.properties,\n p.schema.properties\n );\n }\n\n delete p.contentType;\n delete p.content;\n // in body 不需要处理\n continue;\n }\n\n parameters.push(p);\n }\n // class header 需要使用 ApiHeader 装饰器\n if (header) {\n parameters.unshift(header);\n }\n\n opts[webRouter.requestMethod].parameters = parameters;\n\n const responses = metaForMethods.filter(\n item =>\n item.key === DECORATORS.API_RESPONSE &&\n item.propertyName === webRouter.method\n );\n const returnResponses = {};\n for (const r of responses) {\n const resp = r.metadata;\n const keys = Object.keys(resp);\n for (const k of keys) {\n // 这里是引用,赋值可以直接更改\n const tt = resp[k];\n if (tt.type) {\n if (Types.isClass(tt.type)) {\n this.parseClzz(tt.type);\n\n if (tt.isArray) {\n tt.content = {\n 'application/json': {\n schema: {\n type: 'array',\n items: {\n $ref: '#/components/schemas/' + tt.type.name,\n },\n },\n },\n };\n } else {\n tt.content = {\n 'application/json': {\n schema: {\n $ref: '#/components/schemas/' + tt.type.name,\n },\n },\n };\n }\n } else {\n tt.content = {\n 'text/plan': {\n schema: {\n type: convertSchemaType(tt.type),\n },\n },\n };\n }\n }\n delete tt.status;\n delete tt.type;\n delete tt.isArray;\n delete tt.format;\n }\n\n Object.assign(returnResponses, resp);\n }\n\n if (Object.keys(returnResponses).length > 0) {\n opts[webRouter.requestMethod].responses = returnResponses;\n } else {\n opts[webRouter.requestMethod].responses = {\n 200: {\n description: 'OK',\n },\n };\n }\n\n paths[url] = opts;\n }\n /**\n * 提取参数\n * @param params\n * @param p\n */\n private parseFromParamsToP(paramMeta: any, p: any) {\n if (paramMeta) {\n const param = paramMeta.metadata;\n\n if (param) {\n p.description = param.description;\n if (param.in === 'query') {\n p.allowEmptyValue = param.allowEmptyValue || false;\n }\n if (param.example) {\n p.example = param.example;\n }\n if (param.examples) {\n p.examples = param.examples;\n }\n if (param.deprecated) {\n p.deprecated = param.deprecated;\n }\n if (param.contentType) {\n p.contentType = param.contentType;\n }\n p.in = param?.in ?? p.in;\n p.required = param?.required ?? p.required;\n if (p.in === 'query') {\n p.style = 'form';\n } else if (p.in === 'path' || p.in === 'header') {\n p.style = 'simple';\n } else if (p.in === 'cookie') {\n p.style = 'form';\n }\n p.explode = p.style === 'form';\n // response content\n if (param?.content) {\n p.content = param?.content;\n }\n if (param.schema) {\n p.schema = param.schema;\n } else {\n if (param.type) {\n if (Types.isClass(param.type)) {\n this.parseClzz(param.type);\n\n p.schema = {\n $ref: '#/components/schemas/' + param.type.name,\n };\n }\n\n if (param.isArray) {\n p.schema = {\n type: 'array',\n items: {\n type: p?.schema?.$ref ?? convertSchemaType(param.type),\n format: param.format,\n },\n };\n } else {\n if (!p.schema) {\n p.schema = {\n type: param.type ? convertSchemaType(param.type) : p.type,\n format: param.format || p.format,\n };\n }\n }\n } else if (param.format) {\n p.schema.format = param.format;\n }\n }\n }\n }\n }\n /**\n * 解析类型的 ApiProperty\n * @param clzz\n */\n private parseClzz(clzz: Type) {\n if (this.documentBuilder.getSchema(clzz.name)) {\n return;\n }\n\n const props = getClassMetadata(INJECT_CUSTOM_PROPERTY, clzz);\n\n const tt: any = {\n type: 'object',\n properties: {},\n };\n\n if (props) {\n Object.keys(props).forEach(key => {\n const metadata = props[key].metadata;\n\n if (metadata?.example) {\n if (!tt.example) {\n tt.example = {};\n }\n tt.example[key] = metadata?.example;\n\n delete metadata.example;\n }\n if (metadata?.required !== false) {\n if (!tt.required) {\n tt.required = [];\n }\n tt.required.push(key);\n\n delete metadata.required;\n }\n if (metadata?.enum) {\n tt.properties[key] = {\n type: metadata?.type,\n enum: metadata?.enum,\n default: metadata?.default,\n };\n\n if (metadata?.description) {\n tt.properties[key].description = metadata?.description;\n }\n return;\n }\n if (metadata?.items?.enum) {\n tt.properties[key] = {\n type: metadata?.type,\n items: metadata?.items,\n default: metadata?.default,\n };\n\n if (metadata?.description) {\n tt.properties[key].description = metadata?.description;\n }\n return;\n }\n let isArray = false;\n let currentType = metadata?.type;\n\n delete metadata?.type;\n\n if (currentType === 'array') {\n isArray = true;\n currentType = metadata?.items?.type;\n\n delete metadata.items;\n }\n\n if (Types.isClass(currentType)) {\n this.parseClzz(currentType);\n\n if (isArray) {\n tt.properties[key] = {\n type: 'array',\n items: {\n $ref: '#components/schemas/' + currentType?.name,\n },\n };\n } else {\n tt.properties[key] = {\n $ref: '#components/schemas/' + currentType?.name,\n };\n }\n } else {\n if (isArray) {\n tt.properties[key] = {\n type: 'array',\n items: {\n type: convertSchemaType(currentType?.name || currentType),\n },\n };\n } else {\n tt.properties[key] = {\n type: getPropertyType(clzz.prototype, key).name,\n format: metadata?.format,\n };\n\n delete metadata.format;\n }\n }\n\n Object.assign(tt.properties[key], metadata);\n });\n }\n\n this.documentBuilder.addSchema({\n [clzz.name]: tt,\n });\n }\n /**\n * 授权验证\n * @param opts\n * @returns\n */\n private setAuth(opts: AuthOptions) {\n if (!opts) {\n return;\n }\n const authType = opts.authType;\n delete opts.authType;\n // TODO 加 security\n switch (authType) {\n case 'basic':\n {\n const name = opts.name;\n delete opts.name;\n this.documentBuilder.addBasicAuth(opts as SecuritySchemeObject, name);\n }\n break;\n case 'bearer':\n {\n const name = opts.name;\n delete opts.name;\n this.documentBuilder.addBearerAuth(\n opts as SecuritySchemeObject,\n name\n );\n }\n break;\n case 'cookie':\n {\n const cname = opts.cookieName;\n const secName = opts.securityName;\n delete opts.cookieName;\n delete opts.securityName;\n this.documentBuilder.addCookieAuth(\n cname,\n opts as SecuritySchemeObject,\n secName\n );\n }\n break;\n case 'oauth2':\n {\n const name = opts.name;\n delete opts.name;\n this.documentBuilder.addOAuth2(opts as SecuritySchemeObject, name);\n }\n break;\n case 'apikey':\n {\n const name = opts.name;\n delete opts.name;\n this.documentBuilder.addApiKey(opts as SecuritySchemeObject, name);\n }\n break;\n case 'custom':\n {\n this.documentBuilder.addSecurity(\n opts?.name,\n opts as SecuritySchemeObject\n );\n }\n break;\n }\n }\n}\n/**\n * 解释路由上的参数\n * @param url\n */\nfunction parseParamsInPath(url: string) {\n const names: string[] = [];\n url.split('/').forEach(item => {\n if (item.startsWith(':')) {\n const paramName = item.substr(1);\n names.push(paramName);\n }\n });\n return names;\n}\n/**\n * 替换成 openapi 的url\n * @param url\n * @param names\n */\nfunction replaceUrl(url: string, names: string[]) {\n names.forEach(n => {\n url = url.replace(`:${n}`, `{${n}}`);\n });\n return url;\n}\n\nfunction convertTypeToString(type: RouteParamTypes) {\n switch (type) {\n case RouteParamTypes.HEADERS:\n return 'header';\n case RouteParamTypes.QUERY:\n return 'query';\n case RouteParamTypes.PARAM:\n return 'path';\n case RouteParamTypes.BODY:\n case RouteParamTypes.FIELDS:\n case RouteParamTypes.FILESSTREAM:\n case RouteParamTypes.FILESTREAM:\n return 'body';\n default:\n return 'header';\n }\n}\n\nfunction convertSchemaType(value) {\n switch (value) {\n case 'Object':\n return 'object';\n case 'Boolean':\n return 'boolean';\n case 'Number':\n return 'number';\n case 'String':\n return 'string';\n default:\n return value;\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"swaggerMiddleware.js","sourceRoot":"","sources":["../src/swaggerMiddleware.ts"],"names":[],"mappings":";;;;;;;;;;;;AAMA,yCAA6C;AAC7C,mDAQ6B;AAC7B,2BAAkC;AAClC,+BAAqC;AACrC,uDAAoD;AAIpD,IAAa,iBAAiB,GAA9B,MAAa,iBAAiB;IAY5B,KAAK,CAAC,IAAI;QACR,MAAM,EAAE,iBAAiB,EAAE,GAAG,IAAA,kBAAW,EAAC,iBAAiB,CAAC,CAAC;QAC7D,IAAI,iBAAiB,EAAE;YACrB,IAAI,CAAC,kBAAkB,GAAG,iBAAiB,EAAE,CAAC;SAC/C;IACH,CAAC;IAED,OAAO,CAAC,GAAuB;QAC7B,IAAI,GAAG,CAAC,gBAAgB,EAAE,KAAK,+BAAmB,CAAC,WAAW,EAAE;YAC9D,OAAO,KAAK,EAAE,GAAQ,EAAE,GAAQ,EAAE,IAAkB,EAAE,EAAE;gBACtD,MAAM,QAAQ,GAAG,GAAG,CAAC,IAAI,CAAC;gBAC1B,IACE,CAAC,IAAI,CAAC,kBAAkB;oBACxB,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,EACvD;oBACA,OAAO,IAAI,EAAE,CAAC;iBACf;gBACD,MAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,C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,EAAE,UAAU,CAAC,CAAC;iBAC9C;qBAAM,IAAI,GAAG,KAAK,MAAM,EAAE;oBACxB,GAAW,CAAC,GAAG,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;iBAC/C;gBAEA,GAAW,CAAC,IAAI,GAAG,OAAO,CAAC;YAC9B,CAAC,CAAC;SACH;IACH,CAAC;IAED,MAAM,CAAC,OAAO;QACZ,OAAO,SAAS,CAAC;IACnB,CAAC;CACF,CAAA;AAxGC;IADC,IAAA,kBAAM,EAAC,SAAS,CAAC;;wDACS;AAK3B;IADC,IAAA,kBAAM,GAAE;8BACgB,iCAAe;0DAAC;AAGzC;IADC,IAAA,gBAAI,GAAE;;;;6CAMN;AAjBU,iBAAiB;IAF7B,IAAA,mBAAO,GAAE;IACT,IAAA,iBAAK,EAAC,qBAAS,CAAC,SAAS,CAAC;GACd,iBAAiB,CA4G7B;AA5GY,8CAAiB","sourcesContent":["import type {\n IMiddleware,\n IMidwayApplication,\n IMidwayContext,\n NextFunction,\n} from '@midwayjs/core';\nimport { safeRequire } from '@midwayjs/core';\nimport {\n Config,\n Init,\n Inject,\n Provide,\n Scope,\n ScopeEnum,\n MidwayFrameworkType,\n} from '@midwayjs/decorator';\nimport { readFileSync } from 'fs';\nimport { join, extname } from 'path';\nimport { SwaggerExplorer } from './swaggerExplorer';\n\n@Provide()\n@Scope(ScopeEnum.Singleton)\nexport class SwaggerMiddleware\n implements IMiddleware<IMidwayContext, NextFunction, unknown>\n{\n @Config('swagger')\n private swaggerConfig: any;\n\n private swaggerUiAssetPath: string;\n\n @Inject()\n private swaggerExplorer: SwaggerExplorer;\n\n @Init()\n async init() {\n const { getAbsoluteFSPath } = safeRequire('swagger-ui-dist');\n if (getAbsoluteFSPath) {\n this.swaggerUiAssetPath = getAbsoluteFSPath();\n }\n }\n\n resolve(app: IMidwayApplication) {\n if (app.getFrameworkType() === MidwayFrameworkType.WEB_EXPRESS) {\n return async (req: any, res: any, next: NextFunction) => {\n const pathname = req.path;\n if (\n !this.swaggerUiAssetPath ||\n pathname.indexOf(this.swaggerConfig.swaggerPath) === -1\n ) {\n return next();\n }\n const arr = pathname.split('/');\n let lastName = arr.pop();\n if (lastName === 'index.json') {\n res.send(this.swaggerExplorer.getData());\n return;\n }\n if (!lastName) {\n lastName = 'index.html';\n }\n\n let content = readFileSync(join(this.swaggerUiAssetPath, lastName), {\n encoding: 'utf-8',\n });\n if (lastName === 'index.html') {\n content = content.replace(\n '\"https://petstore.swagger.io/v2/swagger.json\"',\n `location.href.replace('${this.swaggerConfig.swaggerPath}/index.html', '${this.swaggerConfig.swaggerPath}/index.json')`\n );\n }\n const ext = extname(lastName);\n if (ext === '.js') {\n res.type('application/javascript');\n } else if (ext === '.map') {\n res.type('application/json');\n } else if (ext === '.css') {\n res.type('text/css');\n } else if (ext === '.png') {\n res.type('image/png');\n }\n\n res.send(content);\n };\n } else {\n return async (ctx: IMidwayContext, next: NextFunction) => {\n const pathname = (ctx as any).path;\n if (\n !this.swaggerUiAssetPath ||\n pathname.indexOf(this.swaggerConfig.swaggerPath) === -1\n ) {\n return next();\n }\n const arr = pathname.split('/');\n let lastName = arr.pop();\n if (lastName === 'index.json') {\n (ctx as any).body = this.swaggerExplorer.getData();\n return;\n }\n if (!lastName) {\n lastName = 'index.html';\n }\n\n let content = readFileSync(join(this.swaggerUiAssetPath, lastName), {\n encoding: 'utf-8',\n });\n if (lastName === 'index.html') {\n content = content.replace(\n '\"https://petstore.swagger.io/v2/swagger.json\"',\n `location.href.replace('${this.swaggerConfig.swaggerPath}/index.html', '${this.swaggerConfig.swaggerPath}/index.json')`\n );\n }\n const ext = extname(lastName);\n if (ext === '.js') {\n (ctx as any).set('Content-Type', 'application/javascript');\n } else if (ext === '.map') {\n (ctx as any).set('Content-Type', 'application/json');\n } else if (ext === '.css') {\n (ctx as any).set('Content-Type', 'text/css');\n } else if (ext === '.png') {\n (ctx as any).set('Content-Type', 'image/png');\n }\n\n (ctx as any).body = content;\n };\n }\n }\n\n static getName() {\n return 'swagger';\n }\n}\n"]}
package/package.json CHANGED
@@ -1,19 +1,20 @@
1
1
  {
2
2
  "name": "@midwayjs/swagger",
3
- "version": "3.0.0-beta.17",
3
+ "version": "3.0.2",
4
4
  "main": "dist/index",
5
5
  "typings": "index.d.ts",
6
6
  "files": [
7
7
  "dist/**/*.js",
8
8
  "dist/**/*.d.ts",
9
- "index.d.ts"
9
+ "index.d.ts",
10
+ "dist/**/*.js.map"
10
11
  ],
11
12
  "devDependencies": {
12
- "@midwayjs/core": "^3.0.0-beta.17",
13
- "@midwayjs/decorator": "^3.0.0-beta.17",
14
- "@midwayjs/koa": "^3.0.0-beta.17",
15
- "@midwayjs/mock": "^3.0.0-beta.17",
16
- "swagger-ui-dist": "4.1.3"
13
+ "@midwayjs/core": "^3.0.2",
14
+ "@midwayjs/decorator": "^3.0.2",
15
+ "@midwayjs/koa": "^3.0.2",
16
+ "@midwayjs/mock": "^3.0.2",
17
+ "swagger-ui-dist": "4.2.1"
17
18
  },
18
19
  "author": "Kurten Chan <chinkurten@gmail.com>",
19
20
  "license": "MIT",
@@ -27,5 +28,5 @@
27
28
  "type": "git",
28
29
  "url": "https://github.com/midwayjs/midway.git"
29
30
  },
30
- "gitHead": "17a8b5bd3d0b0b21f24dd2f165b5df9097fc3ec4"
31
+ "gitHead": "ca77247d229978a736e79bb208579c014ed226fc"
31
32
  }