@tsed/schema 7.0.0-alpha.1 → 7.0.0-beta.10
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 +14 -0
- package/lib/cjs/components/anyMapper.js +23 -0
- package/lib/cjs/components/anyMapper.js.map +1 -0
- package/lib/cjs/components/classMapper.js +41 -0
- package/lib/cjs/components/classMapper.js.map +1 -0
- package/lib/cjs/components/genericsMapper.js +62 -0
- package/lib/cjs/components/genericsMapper.js.map +1 -0
- package/lib/cjs/components/inheritedClassMapper.js +22 -0
- package/lib/cjs/components/inheritedClassMapper.js.map +1 -0
- package/lib/cjs/components/itemMapper.js +10 -0
- package/lib/cjs/components/itemMapper.js.map +1 -0
- package/lib/cjs/components/lazyRefMapper.js +19 -0
- package/lib/cjs/components/lazyRefMapper.js.map +1 -0
- package/lib/cjs/components/mapMapper.js +25 -0
- package/lib/cjs/components/mapMapper.js.map +1 -0
- package/lib/cjs/components/objectMapper.js +31 -0
- package/lib/cjs/components/objectMapper.js.map +1 -0
- package/lib/cjs/components/ofMapper.js +17 -0
- package/lib/cjs/components/ofMapper.js.map +1 -0
- package/lib/cjs/components/propertiesMapper.js +25 -0
- package/lib/cjs/components/propertiesMapper.js.map +1 -0
- package/lib/cjs/components/schemaMapper.js +95 -0
- package/lib/cjs/components/schemaMapper.js.map +1 -0
- package/lib/cjs/constants/httpMethods.js +46 -0
- package/lib/cjs/constants/httpMethods.js.map +1 -0
- package/lib/cjs/constants/httpStatusMessages.js +26 -0
- package/lib/cjs/constants/httpStatusMessages.js.map +1 -0
- package/lib/cjs/decorators/class/children.js +24 -0
- package/lib/cjs/decorators/class/children.js.map +1 -0
- package/lib/cjs/decorators/collections/collectionContains.js +29 -0
- package/lib/cjs/decorators/collections/collectionContains.js.map +1 -0
- package/lib/cjs/decorators/collections/collectionOf.js +103 -0
- package/lib/cjs/decorators/collections/collectionOf.js.map +1 -0
- package/lib/cjs/decorators/collections/maxItems.js +60 -0
- package/lib/cjs/decorators/collections/maxItems.js.map +1 -0
- package/lib/cjs/decorators/collections/maxProperties.js +83 -0
- package/lib/cjs/decorators/collections/maxProperties.js.map +1 -0
- package/lib/cjs/decorators/collections/minItems.js +64 -0
- package/lib/cjs/decorators/collections/minItems.js.map +1 -0
- package/lib/cjs/decorators/collections/minProperties.js +82 -0
- package/lib/cjs/decorators/collections/minProperties.js.map +1 -0
- package/lib/cjs/decorators/collections/uniqueItems.js +60 -0
- package/lib/cjs/decorators/collections/uniqueItems.js.map +1 -0
- package/lib/cjs/decorators/common/additionalProperties.js +20 -0
- package/lib/cjs/decorators/common/additionalProperties.js.map +1 -0
- package/lib/cjs/decorators/common/allOf.js +22 -0
- package/lib/cjs/decorators/common/allOf.js.map +1 -0
- package/lib/cjs/decorators/common/allow.js +47 -0
- package/lib/cjs/decorators/common/allow.js.map +1 -0
- package/lib/cjs/decorators/common/any.js +46 -0
- package/lib/cjs/decorators/common/any.js.map +1 -0
- package/lib/cjs/decorators/common/anyOf.js +26 -0
- package/lib/cjs/decorators/common/anyOf.js.map +1 -0
- package/lib/cjs/decorators/common/const.js +70 -0
- package/lib/cjs/decorators/common/const.js.map +1 -0
- package/lib/cjs/decorators/common/customKey.js +43 -0
- package/lib/cjs/decorators/common/customKey.js.map +1 -0
- package/lib/cjs/decorators/common/default.js +51 -0
- package/lib/cjs/decorators/common/default.js.map +1 -0
- package/lib/cjs/decorators/common/description.js +76 -0
- package/lib/cjs/decorators/common/description.js.map +1 -0
- package/lib/cjs/decorators/common/enum.js +11 -0
- package/lib/cjs/decorators/common/enum.js.map +1 -0
- package/lib/cjs/decorators/common/example.js +21 -0
- package/lib/cjs/decorators/common/example.js.map +1 -0
- package/lib/cjs/decorators/common/examples.js +21 -0
- package/lib/cjs/decorators/common/examples.js.map +1 -0
- package/lib/cjs/decorators/common/exclusiveMaximum.js +77 -0
- package/lib/cjs/decorators/common/exclusiveMaximum.js.map +1 -0
- package/lib/cjs/decorators/common/exclusiveMinimum.js +77 -0
- package/lib/cjs/decorators/common/exclusiveMinimum.js.map +1 -0
- package/lib/cjs/decorators/common/format.js +486 -0
- package/lib/cjs/decorators/common/format.js.map +1 -0
- package/lib/cjs/decorators/common/forwardGroups.js +20 -0
- package/lib/cjs/decorators/common/forwardGroups.js.map +1 -0
- package/lib/cjs/decorators/common/groups.js +41 -0
- package/lib/cjs/decorators/common/groups.js.map +1 -0
- package/lib/cjs/decorators/common/hidden.js +40 -0
- package/lib/cjs/decorators/common/hidden.js.map +1 -0
- package/lib/cjs/decorators/common/ignore.js +71 -0
- package/lib/cjs/decorators/common/ignore.js.map +1 -0
- package/lib/cjs/decorators/common/integer.js +71 -0
- package/lib/cjs/decorators/common/integer.js.map +1 -0
- package/lib/cjs/decorators/common/jsonEntityFn.js +32 -0
- package/lib/cjs/decorators/common/jsonEntityFn.js.map +1 -0
- package/lib/cjs/decorators/common/maxLength.js +89 -0
- package/lib/cjs/decorators/common/maxLength.js.map +1 -0
- package/lib/cjs/decorators/common/maximum.js +151 -0
- package/lib/cjs/decorators/common/maximum.js.map +1 -0
- package/lib/cjs/decorators/common/minLength.js +90 -0
- package/lib/cjs/decorators/common/minLength.js.map +1 -0
- package/lib/cjs/decorators/common/minimum.js +149 -0
- package/lib/cjs/decorators/common/minimum.js.map +1 -0
- package/lib/cjs/decorators/common/multipleOf.js +81 -0
- package/lib/cjs/decorators/common/multipleOf.js.map +1 -0
- package/lib/cjs/decorators/common/name.js +52 -0
- package/lib/cjs/decorators/common/name.js.map +1 -0
- package/lib/cjs/decorators/common/nullable.js +34 -0
- package/lib/cjs/decorators/common/nullable.js.map +1 -0
- package/lib/cjs/decorators/common/oneOf.js +27 -0
- package/lib/cjs/decorators/common/oneOf.js.map +1 -0
- package/lib/cjs/decorators/common/optional.js +28 -0
- package/lib/cjs/decorators/common/optional.js.map +1 -0
- package/lib/cjs/decorators/common/pattern.js +103 -0
- package/lib/cjs/decorators/common/pattern.js.map +1 -0
- package/lib/cjs/decorators/common/property.js +27 -0
- package/lib/cjs/decorators/common/property.js.map +1 -0
- package/lib/cjs/decorators/common/readOnly.js +21 -0
- package/lib/cjs/decorators/common/readOnly.js.map +1 -0
- package/lib/cjs/decorators/common/recordOf.js +63 -0
- package/lib/cjs/decorators/common/recordOf.js.map +1 -0
- package/lib/cjs/decorators/common/required.js +53 -0
- package/lib/cjs/decorators/common/required.js.map +1 -0
- package/lib/cjs/decorators/common/requiredGroups.js +26 -0
- package/lib/cjs/decorators/common/requiredGroups.js.map +1 -0
- package/lib/cjs/decorators/common/schema.js +68 -0
- package/lib/cjs/decorators/common/schema.js.map +1 -0
- package/lib/cjs/decorators/common/title.js +49 -0
- package/lib/cjs/decorators/common/title.js.map +1 -0
- package/lib/cjs/decorators/common/writeOnly.js +21 -0
- package/lib/cjs/decorators/common/writeOnly.js.map +1 -0
- package/lib/cjs/decorators/config/jsonEntityComponent.js +18 -0
- package/lib/cjs/decorators/config/jsonEntityComponent.js.map +1 -0
- package/lib/cjs/decorators/generics/genericOf.js +99 -0
- package/lib/cjs/decorators/generics/genericOf.js.map +1 -0
- package/lib/cjs/decorators/generics/generics.js +25 -0
- package/lib/cjs/decorators/generics/generics.js.map +1 -0
- package/lib/cjs/decorators/operations/acceptMime.js +28 -0
- package/lib/cjs/decorators/operations/acceptMime.js.map +1 -0
- package/lib/cjs/decorators/operations/consumes.js +39 -0
- package/lib/cjs/decorators/operations/consumes.js.map +1 -0
- package/lib/cjs/decorators/operations/contentType.js +28 -0
- package/lib/cjs/decorators/operations/contentType.js.map +1 -0
- package/lib/cjs/decorators/operations/deprecated.js +43 -0
- package/lib/cjs/decorators/operations/deprecated.js.map +1 -0
- package/lib/cjs/decorators/operations/header.js +59 -0
- package/lib/cjs/decorators/operations/header.js.map +1 -0
- package/lib/cjs/decorators/operations/in.js +80 -0
- package/lib/cjs/decorators/operations/in.js.map +1 -0
- package/lib/cjs/decorators/operations/inFile.js +45 -0
- package/lib/cjs/decorators/operations/inFile.js.map +1 -0
- package/lib/cjs/decorators/operations/location.js +29 -0
- package/lib/cjs/decorators/operations/location.js.map +1 -0
- package/lib/cjs/decorators/operations/operationId.js +24 -0
- package/lib/cjs/decorators/operations/operationId.js.map +1 -0
- package/lib/cjs/decorators/operations/operationPath.js +34 -0
- package/lib/cjs/decorators/operations/operationPath.js.map +1 -0
- package/lib/cjs/decorators/operations/partial.js +18 -0
- package/lib/cjs/decorators/operations/partial.js.map +1 -0
- package/lib/cjs/decorators/operations/path.js +29 -0
- package/lib/cjs/decorators/operations/path.js.map +1 -0
- package/lib/cjs/decorators/operations/produces.js +46 -0
- package/lib/cjs/decorators/operations/produces.js.map +1 -0
- package/lib/cjs/decorators/operations/redirect.js +26 -0
- package/lib/cjs/decorators/operations/redirect.js.map +1 -0
- package/lib/cjs/decorators/operations/returns.js +252 -0
- package/lib/cjs/decorators/operations/returns.js.map +1 -0
- package/lib/cjs/decorators/operations/route.js +200 -0
- package/lib/cjs/decorators/operations/route.js.map +1 -0
- package/lib/cjs/decorators/operations/security.js +43 -0
- package/lib/cjs/decorators/operations/security.js.map +1 -0
- package/lib/cjs/decorators/operations/status.js +133 -0
- package/lib/cjs/decorators/operations/status.js.map +1 -0
- package/lib/cjs/decorators/operations/summary.js +34 -0
- package/lib/cjs/decorators/operations/summary.js.map +1 -0
- package/lib/cjs/decorators/operations/tags.js +52 -0
- package/lib/cjs/decorators/operations/tags.js.map +1 -0
- package/lib/cjs/decorators/operations/view.js +31 -0
- package/lib/cjs/decorators/operations/view.js.map +1 -0
- package/lib/cjs/domain/DecoratorContext.js +88 -0
- package/lib/cjs/domain/DecoratorContext.js.map +1 -0
- package/lib/cjs/domain/JsonAliasMap.js +15 -0
- package/lib/cjs/domain/JsonAliasMap.js.map +1 -0
- package/lib/cjs/domain/JsonClassStore.js +37 -0
- package/lib/cjs/domain/JsonClassStore.js.map +1 -0
- package/lib/cjs/domain/JsonEntityStore.js +166 -0
- package/lib/cjs/domain/JsonEntityStore.js.map +1 -0
- package/lib/cjs/domain/JsonFormatTypes.js +22 -0
- package/lib/cjs/domain/JsonFormatTypes.js.map +1 -0
- package/lib/cjs/domain/JsonLazyRef.js +26 -0
- package/lib/cjs/domain/JsonLazyRef.js.map +1 -0
- package/lib/cjs/domain/JsonMap.js +27 -0
- package/lib/cjs/domain/JsonMap.js.map +1 -0
- package/lib/cjs/domain/JsonMethodStore.js +143 -0
- package/lib/cjs/domain/JsonMethodStore.js.map +1 -0
- package/lib/cjs/domain/JsonOperation.js +235 -0
- package/lib/cjs/domain/JsonOperation.js.map +1 -0
- package/lib/cjs/domain/JsonOperationPathsMap.js +29 -0
- package/lib/cjs/domain/JsonOperationPathsMap.js.map +1 -0
- package/lib/cjs/domain/JsonOperationRoute.js +60 -0
- package/lib/cjs/domain/JsonOperationRoute.js.map +1 -0
- package/lib/cjs/domain/JsonParameter.js +119 -0
- package/lib/cjs/domain/JsonParameter.js.map +1 -0
- package/lib/cjs/domain/JsonParameterStore.js +99 -0
- package/lib/cjs/domain/JsonParameterStore.js.map +1 -0
- package/lib/cjs/domain/JsonParameterTypes.js +27 -0
- package/lib/cjs/domain/JsonParameterTypes.js.map +1 -0
- package/lib/cjs/domain/JsonPropertyStore.js +72 -0
- package/lib/cjs/domain/JsonPropertyStore.js.map +1 -0
- package/lib/cjs/domain/JsonRequestBody.js +32 -0
- package/lib/cjs/domain/JsonRequestBody.js.map +1 -0
- package/lib/cjs/domain/JsonResponse.js +76 -0
- package/lib/cjs/domain/JsonResponse.js.map +1 -0
- package/lib/cjs/domain/JsonSchema.js +716 -0
- package/lib/cjs/domain/JsonSchema.js.map +1 -0
- package/lib/cjs/domain/SpecTypes.js +10 -0
- package/lib/cjs/domain/SpecTypes.js.map +1 -0
- package/lib/cjs/hooks/alterIgnore.js +21 -0
- package/lib/cjs/hooks/alterIgnore.js.map +1 -0
- package/lib/cjs/hooks/alterOneOf.js +14 -0
- package/lib/cjs/hooks/alterOneOf.js.map +1 -0
- package/lib/cjs/hooks/alterRequiredGroups.js +15 -0
- package/lib/cjs/hooks/alterRequiredGroups.js.map +1 -0
- package/lib/cjs/index.js +154 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/interfaces/IgnoreCallback.js +3 -0
- package/lib/cjs/interfaces/IgnoreCallback.js.map +1 -0
- package/lib/cjs/interfaces/JsonHookContext.js +3 -0
- package/lib/cjs/interfaces/JsonHookContext.js.map +1 -0
- package/lib/cjs/interfaces/JsonOpenSpec.js +3 -0
- package/lib/cjs/interfaces/JsonOpenSpec.js.map +1 -0
- package/lib/cjs/interfaces/JsonSchemaOptions.js +3 -0
- package/lib/cjs/interfaces/JsonSchemaOptions.js.map +1 -0
- package/lib/cjs/package.json +3 -0
- package/lib/cjs/registries/JsonSchemaMapperContainer.js +37 -0
- package/lib/cjs/registries/JsonSchemaMapperContainer.js.map +1 -0
- package/lib/cjs/utils/buildPath.js +13 -0
- package/lib/cjs/utils/buildPath.js.map +1 -0
- package/lib/cjs/utils/concatParameters.js +16 -0
- package/lib/cjs/utils/concatParameters.js.map +1 -0
- package/lib/cjs/utils/concatPath.js +8 -0
- package/lib/cjs/utils/concatPath.js.map +1 -0
- package/lib/cjs/utils/defineStatusModel.js +13 -0
- package/lib/cjs/utils/defineStatusModel.js.map +1 -0
- package/lib/cjs/utils/from.js +273 -0
- package/lib/cjs/utils/from.js.map +1 -0
- package/lib/cjs/utils/generateSpec.js +46 -0
- package/lib/cjs/utils/generateSpec.js.map +1 -0
- package/lib/cjs/utils/generics.js +40 -0
- package/lib/cjs/utils/generics.js.map +1 -0
- package/lib/cjs/utils/getComputedType.js +26 -0
- package/lib/cjs/utils/getComputedType.js.map +1 -0
- package/lib/cjs/utils/getInheritedStores.js +23 -0
- package/lib/cjs/utils/getInheritedStores.js.map +1 -0
- package/lib/cjs/utils/getJsonEntityStore.js +18 -0
- package/lib/cjs/utils/getJsonEntityStore.js.map +1 -0
- package/lib/cjs/utils/getJsonPathParameters.js +73 -0
- package/lib/cjs/utils/getJsonPathParameters.js.map +1 -0
- package/lib/cjs/utils/getJsonSchema.js +65 -0
- package/lib/cjs/utils/getJsonSchema.js.map +1 -0
- package/lib/cjs/utils/getJsonType.js +40 -0
- package/lib/cjs/utils/getJsonType.js.map +1 -0
- package/lib/cjs/utils/getOperationsRoutes.js +37 -0
- package/lib/cjs/utils/getOperationsRoutes.js.map +1 -0
- package/lib/cjs/utils/getOperationsStores.js +33 -0
- package/lib/cjs/utils/getOperationsStores.js.map +1 -0
- package/lib/cjs/utils/getPropertiesStores.js +45 -0
- package/lib/cjs/utils/getPropertiesStores.js.map +1 -0
- package/lib/cjs/utils/getRequiredProperties.js +66 -0
- package/lib/cjs/utils/getRequiredProperties.js.map +1 -0
- package/lib/cjs/utils/getSpec.js +102 -0
- package/lib/cjs/utils/getSpec.js.map +1 -0
- package/lib/cjs/utils/getSpecType.js +21 -0
- package/lib/cjs/utils/getSpecType.js.map +1 -0
- package/lib/cjs/utils/isSuccessStatus.js +8 -0
- package/lib/cjs/utils/isSuccessStatus.js.map +1 -0
- package/lib/cjs/utils/mapHeaders.js +29 -0
- package/lib/cjs/utils/mapHeaders.js.map +1 -0
- package/lib/cjs/utils/mapNullableType.js +44 -0
- package/lib/cjs/utils/mapNullableType.js.map +1 -0
- package/lib/cjs/utils/mapOpenSpec.js +41 -0
- package/lib/cjs/utils/mapOpenSpec.js.map +1 -0
- package/lib/cjs/utils/mapOpenSpec2.js +34 -0
- package/lib/cjs/utils/mapOpenSpec2.js.map +1 -0
- package/lib/cjs/utils/mapOpenSpec3.js +26 -0
- package/lib/cjs/utils/mapOpenSpec3.js.map +1 -0
- package/lib/cjs/utils/mapOpenSpecInfo.js +21 -0
- package/lib/cjs/utils/mapOpenSpecInfo.js.map +1 -0
- package/lib/cjs/utils/mapRouteOptions.js +26 -0
- package/lib/cjs/utils/mapRouteOptions.js.map +1 -0
- package/lib/cjs/utils/matchGroups.js +23 -0
- package/lib/cjs/utils/matchGroups.js.map +1 -0
- package/lib/cjs/utils/mergeOperation.js +45 -0
- package/lib/cjs/utils/mergeOperation.js.map +1 -0
- package/lib/cjs/utils/mergeSpec.js +46 -0
- package/lib/cjs/utils/mergeSpec.js.map +1 -0
- package/lib/cjs/utils/operationIdFormatter.js +37 -0
- package/lib/cjs/utils/operationIdFormatter.js.map +1 -0
- package/lib/cjs/utils/ref.js +65 -0
- package/lib/cjs/utils/ref.js.map +1 -0
- package/lib/cjs/utils/serializeEnumValues.js +26 -0
- package/lib/cjs/utils/serializeEnumValues.js.map +1 -0
- package/lib/cjs/utils/toJsonMapCollection.js +15 -0
- package/lib/cjs/utils/toJsonMapCollection.js.map +1 -0
- package/lib/cjs/utils/toJsonRegex.js +12 -0
- package/lib/cjs/utils/toJsonRegex.js.map +1 -0
- package/lib/cjs/utils/transformToOS2.js +510 -0
- package/lib/cjs/utils/transformToOS2.js.map +1 -0
- package/lib/esm/components/anyMapper.js +19 -0
- package/lib/esm/components/anyMapper.js.map +1 -0
- package/lib/esm/components/classMapper.js +37 -0
- package/lib/esm/components/classMapper.js.map +1 -0
- package/lib/esm/components/genericsMapper.js +58 -0
- package/lib/esm/components/genericsMapper.js.map +1 -0
- package/lib/esm/components/inheritedClassMapper.js +18 -0
- package/lib/esm/components/inheritedClassMapper.js.map +1 -0
- package/lib/esm/components/itemMapper.js +6 -0
- package/lib/esm/components/itemMapper.js.map +1 -0
- package/lib/esm/components/lazyRefMapper.js +15 -0
- package/lib/esm/components/lazyRefMapper.js.map +1 -0
- package/lib/esm/components/mapMapper.js +21 -0
- package/lib/esm/components/mapMapper.js.map +1 -0
- package/lib/esm/components/objectMapper.js +27 -0
- package/lib/esm/components/objectMapper.js.map +1 -0
- package/lib/esm/components/ofMapper.js +13 -0
- package/lib/esm/components/ofMapper.js.map +1 -0
- package/lib/esm/components/propertiesMapper.js +21 -0
- package/lib/esm/components/propertiesMapper.js.map +1 -0
- package/lib/esm/components/schemaMapper.js +91 -0
- package/lib/esm/components/schemaMapper.js.map +1 -0
- package/lib/esm/constants/httpMethods.js +43 -0
- package/lib/esm/constants/httpMethods.js.map +1 -0
- package/lib/esm/constants/httpStatusMessages.js +20 -0
- package/lib/esm/constants/httpStatusMessages.js.map +1 -0
- package/lib/esm/decorators/class/children.js +20 -0
- package/lib/esm/decorators/class/children.js.map +1 -0
- package/lib/esm/decorators/collections/collectionContains.js +25 -0
- package/lib/esm/decorators/collections/collectionContains.js.map +1 -0
- package/lib/esm/decorators/collections/collectionOf.js +97 -0
- package/lib/esm/decorators/collections/collectionOf.js.map +1 -0
- package/lib/esm/decorators/collections/maxItems.js +56 -0
- package/lib/esm/decorators/collections/maxItems.js.map +1 -0
- package/lib/esm/decorators/collections/maxProperties.js +79 -0
- package/lib/esm/decorators/collections/maxProperties.js.map +1 -0
- package/lib/esm/decorators/collections/minItems.js +60 -0
- package/lib/esm/decorators/collections/minItems.js.map +1 -0
- package/lib/esm/decorators/collections/minProperties.js +78 -0
- package/lib/esm/decorators/collections/minProperties.js.map +1 -0
- package/lib/esm/decorators/collections/uniqueItems.js +56 -0
- package/lib/esm/decorators/collections/uniqueItems.js.map +1 -0
- package/lib/esm/decorators/common/additionalProperties.js +16 -0
- package/lib/esm/decorators/common/additionalProperties.js.map +1 -0
- package/lib/esm/decorators/common/allOf.js +18 -0
- package/lib/esm/decorators/common/allOf.js.map +1 -0
- package/lib/esm/decorators/common/allow.js +43 -0
- package/lib/esm/decorators/common/allow.js.map +1 -0
- package/lib/esm/decorators/common/any.js +42 -0
- package/lib/esm/decorators/common/any.js.map +1 -0
- package/lib/esm/decorators/common/anyOf.js +22 -0
- package/lib/esm/decorators/common/anyOf.js.map +1 -0
- package/lib/esm/decorators/common/const.js +66 -0
- package/lib/esm/decorators/common/const.js.map +1 -0
- package/lib/esm/decorators/common/customKey.js +38 -0
- package/lib/esm/decorators/common/customKey.js.map +1 -0
- package/lib/esm/decorators/common/default.js +47 -0
- package/lib/esm/decorators/common/default.js.map +1 -0
- package/lib/esm/decorators/common/description.js +72 -0
- package/lib/esm/decorators/common/description.js.map +1 -0
- package/lib/esm/decorators/common/enum.js +7 -0
- package/lib/esm/decorators/common/enum.js.map +1 -0
- package/lib/esm/decorators/common/example.js +17 -0
- package/lib/esm/decorators/common/example.js.map +1 -0
- package/lib/esm/decorators/common/examples.js +17 -0
- package/lib/esm/decorators/common/examples.js.map +1 -0
- package/lib/esm/decorators/common/exclusiveMaximum.js +73 -0
- package/lib/esm/decorators/common/exclusiveMaximum.js.map +1 -0
- package/lib/esm/decorators/common/exclusiveMinimum.js +73 -0
- package/lib/esm/decorators/common/exclusiveMinimum.js.map +1 -0
- package/lib/esm/decorators/common/format.js +476 -0
- package/lib/esm/decorators/common/format.js.map +1 -0
- package/lib/esm/decorators/common/forwardGroups.js +16 -0
- package/lib/esm/decorators/common/forwardGroups.js.map +1 -0
- package/lib/esm/decorators/common/groups.js +37 -0
- package/lib/esm/decorators/common/groups.js.map +1 -0
- package/lib/esm/decorators/common/hidden.js +36 -0
- package/lib/esm/decorators/common/hidden.js.map +1 -0
- package/lib/esm/decorators/common/ignore.js +67 -0
- package/lib/esm/decorators/common/ignore.js.map +1 -0
- package/lib/esm/decorators/common/integer.js +67 -0
- package/lib/esm/decorators/common/integer.js.map +1 -0
- package/lib/esm/decorators/common/jsonEntityFn.js +28 -0
- package/lib/esm/decorators/common/jsonEntityFn.js.map +1 -0
- package/lib/esm/decorators/common/maxLength.js +85 -0
- package/lib/esm/decorators/common/maxLength.js.map +1 -0
- package/lib/esm/decorators/common/maximum.js +146 -0
- package/lib/esm/decorators/common/maximum.js.map +1 -0
- package/lib/esm/decorators/common/minLength.js +86 -0
- package/lib/esm/decorators/common/minLength.js.map +1 -0
- package/lib/esm/decorators/common/minimum.js +144 -0
- package/lib/esm/decorators/common/minimum.js.map +1 -0
- package/lib/esm/decorators/common/multipleOf.js +77 -0
- package/lib/esm/decorators/common/multipleOf.js.map +1 -0
- package/lib/esm/decorators/common/name.js +48 -0
- package/lib/esm/decorators/common/name.js.map +1 -0
- package/lib/esm/decorators/common/nullable.js +30 -0
- package/lib/esm/decorators/common/nullable.js.map +1 -0
- package/lib/esm/decorators/common/oneOf.js +23 -0
- package/lib/esm/decorators/common/oneOf.js.map +1 -0
- package/lib/esm/decorators/common/optional.js +24 -0
- package/lib/esm/decorators/common/optional.js.map +1 -0
- package/lib/esm/decorators/common/pattern.js +99 -0
- package/lib/esm/decorators/common/pattern.js.map +1 -0
- package/lib/esm/decorators/common/property.js +23 -0
- package/lib/esm/decorators/common/property.js.map +1 -0
- package/lib/esm/decorators/common/readOnly.js +17 -0
- package/lib/esm/decorators/common/readOnly.js.map +1 -0
- package/lib/esm/decorators/common/recordOf.js +59 -0
- package/lib/esm/decorators/common/recordOf.js.map +1 -0
- package/lib/esm/decorators/common/required.js +49 -0
- package/lib/esm/decorators/common/required.js.map +1 -0
- package/lib/esm/decorators/common/requiredGroups.js +22 -0
- package/lib/esm/decorators/common/requiredGroups.js.map +1 -0
- package/lib/esm/decorators/common/schema.js +63 -0
- package/lib/esm/decorators/common/schema.js.map +1 -0
- package/lib/esm/decorators/common/title.js +45 -0
- package/lib/esm/decorators/common/title.js.map +1 -0
- package/lib/esm/decorators/common/writeOnly.js +17 -0
- package/lib/esm/decorators/common/writeOnly.js.map +1 -0
- package/lib/esm/decorators/config/jsonEntityComponent.js +14 -0
- package/lib/esm/decorators/config/jsonEntityComponent.js.map +1 -0
- package/lib/esm/decorators/generics/genericOf.js +95 -0
- package/lib/esm/decorators/generics/genericOf.js.map +1 -0
- package/lib/esm/decorators/generics/generics.js +21 -0
- package/lib/esm/decorators/generics/generics.js.map +1 -0
- package/lib/esm/decorators/operations/acceptMime.js +24 -0
- package/lib/esm/decorators/operations/acceptMime.js.map +1 -0
- package/lib/esm/decorators/operations/consumes.js +35 -0
- package/lib/esm/decorators/operations/consumes.js.map +1 -0
- package/lib/esm/decorators/operations/contentType.js +24 -0
- package/lib/esm/decorators/operations/contentType.js.map +1 -0
- package/lib/esm/decorators/operations/deprecated.js +39 -0
- package/lib/esm/decorators/operations/deprecated.js.map +1 -0
- package/lib/esm/decorators/operations/header.js +55 -0
- package/lib/esm/decorators/operations/header.js.map +1 -0
- package/lib/esm/decorators/operations/in.js +76 -0
- package/lib/esm/decorators/operations/in.js.map +1 -0
- package/lib/esm/decorators/operations/inFile.js +41 -0
- package/lib/esm/decorators/operations/inFile.js.map +1 -0
- package/lib/esm/decorators/operations/location.js +25 -0
- package/lib/esm/decorators/operations/location.js.map +1 -0
- package/lib/esm/decorators/operations/operationId.js +20 -0
- package/lib/esm/decorators/operations/operationId.js.map +1 -0
- package/lib/esm/decorators/operations/operationPath.js +30 -0
- package/lib/esm/decorators/operations/operationPath.js.map +1 -0
- package/lib/esm/decorators/operations/partial.js +14 -0
- package/lib/esm/decorators/operations/partial.js.map +1 -0
- package/lib/esm/decorators/operations/path.js +25 -0
- package/lib/esm/decorators/operations/path.js.map +1 -0
- package/lib/esm/decorators/operations/produces.js +42 -0
- package/lib/esm/decorators/operations/produces.js.map +1 -0
- package/lib/esm/decorators/operations/redirect.js +22 -0
- package/lib/esm/decorators/operations/redirect.js.map +1 -0
- package/lib/esm/decorators/operations/returns.js +248 -0
- package/lib/esm/decorators/operations/returns.js.map +1 -0
- package/lib/esm/decorators/operations/route.js +188 -0
- package/lib/esm/decorators/operations/route.js.map +1 -0
- package/lib/esm/decorators/operations/security.js +39 -0
- package/lib/esm/decorators/operations/security.js.map +1 -0
- package/lib/esm/decorators/operations/status.js +129 -0
- package/lib/esm/decorators/operations/status.js.map +1 -0
- package/lib/esm/decorators/operations/summary.js +30 -0
- package/lib/esm/decorators/operations/summary.js.map +1 -0
- package/lib/esm/decorators/operations/tags.js +48 -0
- package/lib/esm/decorators/operations/tags.js.map +1 -0
- package/lib/esm/decorators/operations/view.js +27 -0
- package/lib/esm/decorators/operations/view.js.map +1 -0
- package/lib/esm/domain/DecoratorContext.js +84 -0
- package/lib/esm/domain/DecoratorContext.js.map +1 -0
- package/lib/esm/domain/JsonAliasMap.js +11 -0
- package/lib/esm/domain/JsonAliasMap.js.map +1 -0
- package/lib/esm/domain/JsonClassStore.js +34 -0
- package/lib/esm/domain/JsonClassStore.js.map +1 -0
- package/lib/esm/domain/JsonEntityStore.js +162 -0
- package/lib/esm/domain/JsonEntityStore.js.map +1 -0
- package/lib/esm/domain/JsonFormatTypes.js +19 -0
- package/lib/esm/domain/JsonFormatTypes.js.map +1 -0
- package/lib/esm/domain/JsonLazyRef.js +22 -0
- package/lib/esm/domain/JsonLazyRef.js.map +1 -0
- package/lib/esm/domain/JsonMap.js +23 -0
- package/lib/esm/domain/JsonMap.js.map +1 -0
- package/lib/esm/domain/JsonMethodStore.js +140 -0
- package/lib/esm/domain/JsonMethodStore.js.map +1 -0
- package/lib/esm/domain/JsonOperation.js +231 -0
- package/lib/esm/domain/JsonOperation.js.map +1 -0
- package/lib/esm/domain/JsonOperationPathsMap.js +25 -0
- package/lib/esm/domain/JsonOperationPathsMap.js.map +1 -0
- package/lib/esm/domain/JsonOperationRoute.js +56 -0
- package/lib/esm/domain/JsonOperationRoute.js.map +1 -0
- package/lib/esm/domain/JsonParameter.js +115 -0
- package/lib/esm/domain/JsonParameter.js.map +1 -0
- package/lib/esm/domain/JsonParameterStore.js +96 -0
- package/lib/esm/domain/JsonParameterStore.js.map +1 -0
- package/lib/esm/domain/JsonParameterTypes.js +22 -0
- package/lib/esm/domain/JsonParameterTypes.js.map +1 -0
- package/lib/esm/domain/JsonPropertyStore.js +69 -0
- package/lib/esm/domain/JsonPropertyStore.js.map +1 -0
- package/lib/esm/domain/JsonRequestBody.js +28 -0
- package/lib/esm/domain/JsonRequestBody.js.map +1 -0
- package/lib/esm/domain/JsonResponse.js +71 -0
- package/lib/esm/domain/JsonResponse.js.map +1 -0
- package/lib/esm/domain/JsonSchema.js +712 -0
- package/lib/esm/domain/JsonSchema.js.map +1 -0
- package/lib/esm/domain/SpecTypes.js +7 -0
- package/lib/esm/domain/SpecTypes.js.map +1 -0
- package/lib/esm/hooks/alterIgnore.js +17 -0
- package/lib/esm/hooks/alterIgnore.js.map +1 -0
- package/lib/esm/hooks/alterOneOf.js +10 -0
- package/lib/esm/hooks/alterOneOf.js.map +1 -0
- package/lib/esm/hooks/alterRequiredGroups.js +11 -0
- package/lib/esm/hooks/alterRequiredGroups.js.map +1 -0
- package/lib/esm/index.js +151 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/interfaces/IgnoreCallback.js +2 -0
- package/lib/esm/interfaces/IgnoreCallback.js.map +1 -0
- package/lib/esm/interfaces/JsonHookContext.js +2 -0
- package/lib/esm/interfaces/JsonHookContext.js.map +1 -0
- package/lib/esm/interfaces/JsonOpenSpec.js +2 -0
- package/lib/esm/interfaces/JsonOpenSpec.js.map +1 -0
- package/lib/esm/interfaces/JsonSchemaOptions.js +2 -0
- package/lib/esm/interfaces/JsonSchemaOptions.js.map +1 -0
- package/lib/esm/package.json +3 -0
- package/lib/esm/registries/JsonSchemaMapperContainer.js +30 -0
- package/lib/esm/registries/JsonSchemaMapperContainer.js.map +1 -0
- package/lib/esm/utils/buildPath.js +9 -0
- package/lib/esm/utils/buildPath.js.map +1 -0
- package/lib/esm/utils/concatParameters.js +12 -0
- package/lib/esm/utils/concatParameters.js.map +1 -0
- package/lib/esm/utils/concatPath.js +4 -0
- package/lib/esm/utils/concatPath.js.map +1 -0
- package/lib/esm/utils/defineStatusModel.js +8 -0
- package/lib/esm/utils/defineStatusModel.js.map +1 -0
- package/lib/esm/utils/from.js +250 -0
- package/lib/esm/utils/from.js.map +1 -0
- package/lib/esm/utils/generateSpec.js +41 -0
- package/lib/esm/utils/generateSpec.js.map +1 -0
- package/lib/esm/utils/generics.js +34 -0
- package/lib/esm/utils/generics.js.map +1 -0
- package/lib/esm/utils/getComputedType.js +22 -0
- package/lib/esm/utils/getComputedType.js.map +1 -0
- package/lib/esm/utils/getInheritedStores.js +19 -0
- package/lib/esm/utils/getInheritedStores.js.map +1 -0
- package/lib/esm/utils/getJsonEntityStore.js +14 -0
- package/lib/esm/utils/getJsonEntityStore.js.map +1 -0
- package/lib/esm/utils/getJsonPathParameters.js +69 -0
- package/lib/esm/utils/getJsonPathParameters.js.map +1 -0
- package/lib/esm/utils/getJsonSchema.js +61 -0
- package/lib/esm/utils/getJsonSchema.js.map +1 -0
- package/lib/esm/utils/getJsonType.js +36 -0
- package/lib/esm/utils/getJsonType.js.map +1 -0
- package/lib/esm/utils/getOperationsRoutes.js +33 -0
- package/lib/esm/utils/getOperationsRoutes.js.map +1 -0
- package/lib/esm/utils/getOperationsStores.js +29 -0
- package/lib/esm/utils/getOperationsStores.js.map +1 -0
- package/lib/esm/utils/getPropertiesStores.js +40 -0
- package/lib/esm/utils/getPropertiesStores.js.map +1 -0
- package/lib/esm/utils/getRequiredProperties.js +62 -0
- package/lib/esm/utils/getRequiredProperties.js.map +1 -0
- package/lib/esm/utils/getSpec.js +98 -0
- package/lib/esm/utils/getSpec.js.map +1 -0
- package/lib/esm/utils/getSpecType.js +16 -0
- package/lib/esm/utils/getSpecType.js.map +1 -0
- package/lib/esm/utils/isSuccessStatus.js +3 -0
- package/lib/esm/utils/isSuccessStatus.js.map +1 -0
- package/lib/esm/utils/mapHeaders.js +25 -0
- package/lib/esm/utils/mapHeaders.js.map +1 -0
- package/lib/esm/utils/mapNullableType.js +40 -0
- package/lib/esm/utils/mapNullableType.js.map +1 -0
- package/lib/esm/utils/mapOpenSpec.js +37 -0
- package/lib/esm/utils/mapOpenSpec.js.map +1 -0
- package/lib/esm/utils/mapOpenSpec2.js +30 -0
- package/lib/esm/utils/mapOpenSpec2.js.map +1 -0
- package/lib/esm/utils/mapOpenSpec3.js +22 -0
- package/lib/esm/utils/mapOpenSpec3.js.map +1 -0
- package/lib/esm/utils/mapOpenSpecInfo.js +17 -0
- package/lib/esm/utils/mapOpenSpecInfo.js.map +1 -0
- package/lib/esm/utils/mapRouteOptions.js +22 -0
- package/lib/esm/utils/mapRouteOptions.js.map +1 -0
- package/lib/esm/utils/matchGroups.js +18 -0
- package/lib/esm/utils/matchGroups.js.map +1 -0
- package/lib/esm/utils/mergeOperation.js +41 -0
- package/lib/esm/utils/mergeOperation.js.map +1 -0
- package/lib/esm/utils/mergeSpec.js +42 -0
- package/lib/esm/utils/mergeSpec.js.map +1 -0
- package/lib/esm/utils/operationIdFormatter.js +33 -0
- package/lib/esm/utils/operationIdFormatter.js.map +1 -0
- package/lib/esm/utils/ref.js +59 -0
- package/lib/esm/utils/ref.js.map +1 -0
- package/lib/esm/utils/serializeEnumValues.js +21 -0
- package/lib/esm/utils/serializeEnumValues.js.map +1 -0
- package/lib/esm/utils/toJsonMapCollection.js +11 -0
- package/lib/esm/utils/toJsonMapCollection.js.map +1 -0
- package/lib/esm/utils/toJsonRegex.js +8 -0
- package/lib/esm/utils/toJsonRegex.js.map +1 -0
- package/lib/esm/utils/transformToOS2.js +504 -0
- package/lib/esm/utils/transformToOS2.js.map +1 -0
- package/lib/{components → types/components}/anyMapper.d.ts +0 -0
- package/lib/{components → types/components}/classMapper.d.ts +1 -1
- package/lib/{components → types/components}/genericsMapper.d.ts +0 -0
- package/lib/{components → types/components}/inheritedClassMapper.d.ts +1 -1
- package/lib/{components → types/components}/itemMapper.d.ts +0 -0
- package/lib/types/components/lazyRefMapper.d.ts +3 -0
- package/lib/{components → types/components}/mapMapper.d.ts +1 -1
- package/lib/{components → types/components}/objectMapper.d.ts +0 -0
- package/lib/types/components/ofMapper.d.ts +3 -0
- package/lib/types/components/propertiesMapper.d.ts +3 -0
- package/lib/{components → types/components}/schemaMapper.d.ts +1 -1
- package/lib/types/constants/httpMethods.d.ts +12 -0
- package/lib/types/constants/httpStatusMessages.d.ts +11 -0
- package/lib/types/decorators/class/children.d.ts +11 -0
- package/lib/{decorators → types/decorators}/collections/collectionContains.d.ts +0 -0
- package/lib/{decorators → types/decorators}/collections/collectionOf.d.ts +1 -1
- package/lib/{decorators → types/decorators}/collections/maxItems.d.ts +0 -0
- package/lib/{decorators → types/decorators}/collections/maxProperties.d.ts +0 -0
- package/lib/{decorators → types/decorators}/collections/minItems.d.ts +0 -0
- package/lib/{decorators → types/decorators}/collections/minProperties.d.ts +0 -0
- package/lib/{decorators → types/decorators}/collections/uniqueItems.d.ts +0 -0
- package/lib/{decorators → types/decorators}/common/additionalProperties.d.ts +0 -0
- package/lib/{decorators → types/decorators}/common/allOf.d.ts +0 -0
- package/lib/{decorators → types/decorators}/common/allow.d.ts +0 -0
- package/lib/{decorators → types/decorators}/common/any.d.ts +1 -1
- package/lib/{decorators → types/decorators}/common/anyOf.d.ts +0 -0
- package/lib/{decorators → types/decorators}/common/const.d.ts +1 -1
- package/lib/{decorators → types/decorators}/common/customKey.d.ts +0 -0
- package/lib/{decorators → types/decorators}/common/default.d.ts +0 -0
- package/lib/{decorators → types/decorators}/common/description.d.ts +0 -0
- package/lib/{decorators → types/decorators}/common/enum.d.ts +1 -1
- package/lib/{decorators → types/decorators}/common/example.d.ts +0 -0
- package/lib/types/decorators/common/examples.d.ts +12 -0
- package/lib/{decorators → types/decorators}/common/exclusiveMaximum.d.ts +0 -0
- package/lib/{decorators → types/decorators}/common/exclusiveMinimum.d.ts +0 -0
- package/lib/{decorators → types/decorators}/common/format.d.ts +0 -0
- package/lib/{decorators → types/decorators}/common/forwardGroups.d.ts +0 -0
- package/lib/{decorators → types/decorators}/common/groups.d.ts +0 -0
- package/lib/{decorators → types/decorators}/common/hidden.d.ts +0 -0
- package/lib/{decorators → types/decorators}/common/ignore.d.ts +1 -1
- package/lib/{decorators → types/decorators}/common/integer.d.ts +0 -0
- package/lib/{decorators → types/decorators}/common/jsonEntityFn.d.ts +2 -2
- package/lib/{decorators → types/decorators}/common/maxLength.d.ts +0 -0
- package/lib/{decorators → types/decorators}/common/maximum.d.ts +0 -0
- package/lib/{decorators → types/decorators}/common/minLength.d.ts +0 -0
- package/lib/{decorators → types/decorators}/common/minimum.d.ts +0 -0
- package/lib/{decorators → types/decorators}/common/multipleOf.d.ts +0 -0
- package/lib/{decorators → types/decorators}/common/name.d.ts +0 -0
- package/lib/{decorators → types/decorators}/common/nullable.d.ts +1 -1
- package/lib/{decorators → types/decorators}/common/oneOf.d.ts +0 -0
- package/lib/{decorators → types/decorators}/common/optional.d.ts +0 -0
- package/lib/{decorators → types/decorators}/common/pattern.d.ts +0 -0
- package/lib/{decorators → types/decorators}/common/property.d.ts +1 -0
- package/lib/{decorators → types/decorators}/common/readOnly.d.ts +0 -0
- package/lib/types/decorators/common/recordOf.d.ts +46 -0
- package/lib/{decorators → types/decorators}/common/required.d.ts +0 -0
- package/lib/{decorators → types/decorators}/common/requiredGroups.d.ts +1 -1
- package/lib/{decorators → types/decorators}/common/schema.d.ts +0 -0
- package/lib/{decorators → types/decorators}/common/title.d.ts +0 -0
- package/lib/{decorators → types/decorators}/common/writeOnly.d.ts +0 -0
- package/lib/{decorators → types/decorators}/config/jsonEntityComponent.d.ts +0 -0
- package/lib/{decorators → types/decorators}/generics/genericOf.d.ts +0 -0
- package/lib/{decorators → types/decorators}/generics/generics.d.ts +0 -0
- package/lib/types/decorators/operations/acceptMime.d.ts +19 -0
- package/lib/{decorators → types/decorators}/operations/consumes.d.ts +0 -0
- package/lib/{decorators → types/decorators}/operations/contentType.d.ts +0 -0
- package/lib/{decorators → types/decorators}/operations/deprecated.d.ts +0 -0
- package/lib/{decorators → types/decorators}/operations/header.d.ts +0 -0
- package/lib/{decorators → types/decorators}/operations/in.d.ts +1 -1
- package/lib/types/decorators/operations/inFile.d.ts +25 -0
- package/lib/{decorators → types/decorators}/operations/location.d.ts +0 -0
- package/lib/{decorators → types/decorators}/operations/operationId.d.ts +0 -0
- package/lib/{decorators → types/decorators}/operations/operationPath.d.ts +1 -11
- package/lib/{decorators → types/decorators}/operations/partial.d.ts +0 -0
- package/lib/{decorators → types/decorators}/operations/path.d.ts +0 -0
- package/lib/{decorators → types/decorators}/operations/produces.d.ts +0 -0
- package/lib/{decorators → types/decorators}/operations/redirect.d.ts +0 -0
- package/lib/{decorators → types/decorators}/operations/returns.d.ts +16 -1
- package/lib/types/decorators/operations/route.d.ts +188 -0
- package/lib/{decorators → types/decorators}/operations/security.d.ts +0 -0
- package/lib/{decorators → types/decorators}/operations/status.d.ts +0 -0
- package/lib/{decorators → types/decorators}/operations/summary.d.ts +0 -0
- package/lib/{decorators → types/decorators}/operations/tags.d.ts +0 -0
- package/lib/types/decorators/operations/view.d.ts +23 -0
- package/lib/{domain → types/domain}/DecoratorContext.d.ts +7 -2
- package/lib/{domain → types/domain}/JsonAliasMap.d.ts +0 -0
- package/lib/types/domain/JsonClassStore.d.ts +12 -0
- package/lib/types/domain/JsonEntityStore.d.ts +136 -0
- package/lib/{domain → types/domain}/JsonFormatTypes.d.ts +0 -0
- package/lib/{domain → types/domain}/JsonLazyRef.d.ts +0 -0
- package/lib/{domain → types/domain}/JsonMap.d.ts +1 -1
- package/lib/types/domain/JsonMethodStore.d.ts +89 -0
- package/lib/{domain → types/domain}/JsonOperation.d.ts +3 -1
- package/lib/types/domain/JsonOperationPathsMap.d.ts +7 -0
- package/lib/types/domain/JsonOperationRoute.d.ts +26 -0
- package/lib/{domain → types/domain}/JsonParameter.d.ts +5 -2
- package/lib/types/domain/JsonParameterStore.d.ts +52 -0
- package/lib/{domain → types/domain}/JsonParameterTypes.d.ts +0 -0
- package/lib/types/domain/JsonPropertyStore.d.ts +30 -0
- package/lib/{domain → types/domain}/JsonRequestBody.d.ts +0 -0
- package/lib/{domain → types/domain}/JsonResponse.d.ts +2 -1
- package/lib/{domain → types/domain}/JsonSchema.d.ts +8 -14
- package/lib/{domain → types/domain}/SpecTypes.d.ts +0 -0
- package/lib/{hooks → types/hooks}/alterIgnore.d.ts +0 -0
- package/lib/types/hooks/alterOneOf.d.ts +3 -0
- package/lib/{hooks → types/hooks}/alterRequiredGroups.d.ts +0 -0
- package/lib/types/index.d.ts +150 -0
- package/lib/{interfaces → types/interfaces}/IgnoreCallback.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/JsonHookContext.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/JsonOpenSpec.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/JsonSchemaOptions.d.ts +0 -0
- package/lib/{registries → types/registries}/JsonSchemaMapperContainer.d.ts +3 -2
- package/lib/{utils → types/utils}/buildPath.d.ts +0 -0
- package/lib/{utils → types/utils}/concatParameters.d.ts +0 -0
- package/lib/types/utils/concatPath.d.ts +1 -0
- package/lib/{utils → types/utils}/defineStatusModel.d.ts +0 -0
- package/lib/{utils → types/utils}/from.d.ts +0 -0
- package/lib/types/utils/generateSpec.d.ts +16 -0
- package/lib/{utils → types/utils}/generics.d.ts +1 -1
- package/lib/{utils → types/utils}/getComputedType.d.ts +0 -0
- package/lib/{utils → types/utils}/getInheritedStores.d.ts +2 -2
- package/lib/types/utils/getJsonEntityStore.d.ts +15 -0
- package/lib/{utils → types/utils}/getJsonPathParameters.d.ts +0 -0
- package/lib/types/utils/getJsonSchema.d.ts +14 -0
- package/lib/{utils → types/utils}/getJsonType.d.ts +0 -0
- package/lib/types/utils/getOperationsRoutes.d.ts +8 -0
- package/lib/types/utils/getOperationsStores.d.ts +6 -0
- package/lib/types/utils/getPropertiesStores.d.ts +20 -0
- package/lib/{utils → types/utils}/getRequiredProperties.d.ts +0 -0
- package/lib/types/utils/getSpec.d.ts +30 -0
- package/lib/types/utils/getSpecType.d.ts +12 -0
- package/lib/{utils → types/utils}/isSuccessStatus.d.ts +0 -0
- package/lib/{utils → types/utils}/mapHeaders.d.ts +0 -0
- package/lib/{utils → types/utils}/mapNullableType.d.ts +1 -1
- package/lib/types/utils/mapOpenSpec.d.ts +10 -0
- package/lib/types/utils/mapOpenSpec2.d.ts +9 -0
- package/lib/types/utils/mapOpenSpec3.d.ts +8 -0
- package/lib/types/utils/mapOpenSpecInfo.d.ts +6 -0
- package/lib/types/utils/mapRouteOptions.d.ts +5 -0
- package/lib/{utils → types/utils}/matchGroups.d.ts +0 -0
- package/lib/{utils → types/utils}/mergeOperation.d.ts +0 -0
- package/lib/{utils → types/utils}/mergeSpec.d.ts +0 -0
- package/lib/{utils → types/utils}/operationIdFormatter.d.ts +0 -0
- package/lib/types/utils/ref.d.ts +14 -0
- package/lib/types/utils/serializeEnumValues.d.ts +5 -0
- package/lib/{utils → types/utils}/toJsonMapCollection.d.ts +0 -0
- package/lib/{utils → types/utils}/toJsonRegex.d.ts +0 -0
- package/lib/types/utils/transformToOS2.d.ts +25 -0
- package/package.json +43 -21
- package/readme.md +1 -0
- package/tsconfig.compile.esm.json +13 -0
- package/lib/components/index.d.ts +0 -9
- package/lib/components/lazyRefMapper.d.ts +0 -19
- package/lib/constants/httpStatusMessages.d.ts +0 -5
- package/lib/decorators/index.d.ts +0 -64
- package/lib/domain/JsonEntityStore.d.ts +0 -94
- package/lib/domain/index.d.ts +0 -11
- package/lib/index.d.ts +0 -16
- package/lib/index.js +0 -7632
- package/lib/index.js.map +0 -1
- package/lib/index.modern.js +0 -7499
- package/lib/index.modern.js.map +0 -1
- package/lib/interfaces/index.d.ts +0 -4
- package/lib/registries/JsonEntitiesContainer.d.ts +0 -6
- package/lib/utils/getJsonEntityStore.d.ts +0 -6
- package/lib/utils/getJsonSchema.d.ts +0 -5
- package/lib/utils/getOperationsStores.d.ts +0 -6
- package/lib/utils/getPropertiesStores.d.ts +0 -20
- package/lib/utils/getSpec.d.ts +0 -49
- package/lib/utils/isJsonClass.d.ts +0 -4
- package/lib/utils/mergeSpec.benchmark.d.ts +0 -1
- package/lib/utils/ref.d.ts +0 -46
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { decorateMethodsOf, DecoratorTypes, UnsupportedDecoratorType } from "@tsed/core";
|
|
2
|
+
import { JsonEntityFn } from "../common/jsonEntityFn.js";
|
|
3
|
+
/**
|
|
4
|
+
* Add produces metadata on the decorated element.
|
|
5
|
+
*
|
|
6
|
+
* ## Examples
|
|
7
|
+
* ### On method
|
|
8
|
+
*
|
|
9
|
+
* ```typescript
|
|
10
|
+
* class Model {
|
|
11
|
+
* @Produces("text/html")
|
|
12
|
+
* id: string;
|
|
13
|
+
* }
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* ::: warning
|
|
17
|
+
* For openspec v3 prefer `@Returns().ContentType()` usage (see @@Returns@@).
|
|
18
|
+
* :::
|
|
19
|
+
*
|
|
20
|
+
* @param produces
|
|
21
|
+
* @decorator
|
|
22
|
+
* @swagger
|
|
23
|
+
* @methodDecorator
|
|
24
|
+
* @classDecorator
|
|
25
|
+
* @operation
|
|
26
|
+
* @response
|
|
27
|
+
*/
|
|
28
|
+
export function Produces(...produces) {
|
|
29
|
+
return JsonEntityFn((store, args) => {
|
|
30
|
+
switch (store.decoratorType) {
|
|
31
|
+
case DecoratorTypes.METHOD:
|
|
32
|
+
store.operation.produces(produces);
|
|
33
|
+
break;
|
|
34
|
+
case DecoratorTypes.CLASS:
|
|
35
|
+
decorateMethodsOf(args[0], Produces(...produces));
|
|
36
|
+
break;
|
|
37
|
+
default:
|
|
38
|
+
throw new UnsupportedDecoratorType(Produces, args);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=produces.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"produces.js","sourceRoot":"","sources":["../../../../src/decorators/operations/produces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAE,cAAc,EAAE,wBAAwB,EAAC,MAAM,YAAY,CAAC;AACvF,OAAO,EAAC,YAAY,EAAC,MAAM,wBAAwB,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAG,QAAkB;IAC5C,OAAO,YAAY,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;QAClC,QAAQ,KAAK,CAAC,aAAa,EAAE;YAC3B,KAAK,cAAc,CAAC,MAAM;gBACxB,KAAK,CAAC,SAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;gBACpC,MAAM;YACR,KAAK,cAAc,CAAC,KAAK;gBACvB,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC;gBAClD,MAAM;YAER;gBACE,MAAM,IAAI,wBAAwB,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;SACtD;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {decorateMethodsOf, DecoratorTypes, UnsupportedDecoratorType} from \"@tsed/core\";\nimport {JsonEntityFn} from \"../common/jsonEntityFn\";\n\n/**\n * Add produces metadata on the decorated element.\n *\n * ## Examples\n * ### On method\n *\n * ```typescript\n * class Model {\n * @Produces(\"text/html\")\n * id: string;\n * }\n * ```\n *\n * ::: warning\n * For openspec v3 prefer `@Returns().ContentType()` usage (see @@Returns@@).\n * :::\n *\n * @param produces\n * @decorator\n * @swagger\n * @methodDecorator\n * @classDecorator\n * @operation\n * @response\n */\nexport function Produces(...produces: string[]) {\n return JsonEntityFn((store, args) => {\n switch (store.decoratorType) {\n case DecoratorTypes.METHOD:\n store.operation!.produces(produces);\n break;\n case DecoratorTypes.CLASS:\n decorateMethodsOf(args[0], Produces(...produces));\n break;\n\n default:\n throw new UnsupportedDecoratorType(Produces, args);\n }\n });\n}\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { isNumber, isString, useDecorators } from "@tsed/core";
|
|
2
|
+
import { JsonEntityFn } from "../common/jsonEntityFn.js";
|
|
3
|
+
import { Returns } from "./returns.js";
|
|
4
|
+
export function Redirect(...args) {
|
|
5
|
+
const { status, url, meta } = args.reduce((options, value) => {
|
|
6
|
+
if (isNumber(value)) {
|
|
7
|
+
options.status = value;
|
|
8
|
+
return options;
|
|
9
|
+
}
|
|
10
|
+
if (isString(value)) {
|
|
11
|
+
options.url = value;
|
|
12
|
+
return options;
|
|
13
|
+
}
|
|
14
|
+
options.meta = value;
|
|
15
|
+
return options;
|
|
16
|
+
}, { status: 302, url: "", meta: {} });
|
|
17
|
+
return useDecorators(Returns(status).Location(url, meta), JsonEntityFn((entity) => {
|
|
18
|
+
var _a;
|
|
19
|
+
(_a = entity.operation) === null || _a === void 0 ? void 0 : _a.setRedirection(status);
|
|
20
|
+
}));
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=redirect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redirect.js","sourceRoot":"","sources":["../../../../src/decorators/operations/redirect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;AAE7D,OAAO,EAAC,YAAY,EAAC,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAqDlC,MAAM,UAAU,QAAQ,CAAC,GAAG,IAAW;IACrC,MAAM,EAAC,MAAM,EAAE,GAAG,EAAE,IAAI,EAAC,GAAG,IAAI,CAAC,MAAM,CACrC,CAAC,OAAY,EAAE,KAAU,EAAE,EAAE;QAC3B,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE;YACnB,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC;YACvB,OAAO,OAAO,CAAC;SAChB;QAED,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE;YACnB,OAAO,CAAC,GAAG,GAAG,KAAK,CAAC;YACpB,OAAO,OAAO,CAAC;SAChB;QAED,OAAO,CAAC,IAAI,GAAG,KAAK,CAAC;QACrB,OAAO,OAAO,CAAC;IACjB,CAAC,EACD,EAAC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAC,CACjC,CAAC;IACF,OAAO,aAAa,CAClB,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,EACnC,YAAY,CAAC,CAAC,MAAM,EAAE,EAAE;;QACtB,MAAA,MAAM,CAAC,SAAS,0CAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IAC3C,CAAC,CAAC,CACH,CAAC;AACJ,CAAC","sourcesContent":["import {isNumber, isString, useDecorators} from \"@tsed/core\";\nimport {JsonHeader} from \"../../interfaces/JsonOpenSpec\";\nimport {JsonEntityFn} from \"../common/jsonEntityFn\";\nimport {Returns} from \"./returns\";\n\n/**\n * Redirects to the URL derived from the specified path, with specified status, a positive integer that corresponds to an HTTP status code . If not specified, status defaults to “302 “Found”.\n *\n * ```typescript\n * @Redirect('/foo/bar')\n * @Redirect(301, 'http://example.com').Type(Model)\n * private myMethod() {}\n * ```\n * Redirects can be a fully-qualified URL for redirecting to a different site:\n *\n * ```typescript\n * @Redirect('http://google.com');\n * private myMethod() {}\n * ```\n *\n * Redirects can be relative to the root of the host name. For example, if the application is on http://example.com/admin/post/new, the following would redirect to the URL http://example.com/admin:\n *\n * ```typescript\n * @Redirect('/admin');\n * ```\n * Redirects can be relative to the current URL. For example, from http://example.com/blog/admin/ (notice the trailing slash), the following would redirect to the URL http://example.com/blog/admin/post/new.\n *\n * ```typescript\n * @Redirect('post/new');\n * ```\n *\n * Redirecting to post/new from http://example.com/blog/admin (no trailing slash), will redirect to http://example.com/blog/post/new.\n *\n * If you found the above behavior confusing, think of path segments as directories (with trailing slashes) and files, it will start to make sense.\n *\n * Path-relative redirects are also possible. If you were on http://example.com/admin/post/new, the following would redirect to http//example.com/admin/post:\n *\n * ```typescript\n * @Redirect('..');\n * ``\n *\n * A back redirection redirects the request back to the referer, defaulting to / when the referer is missing.\n *\n * ```typescript\n * @Redirect('back');\n * ```\n *\n * @param url\n * @param meta\n * @decorator\n * @operation\n * @response\n * @headers\n */\nexport function Redirect(url: string, meta?: JsonHeader): Function;\nexport function Redirect(status: number, url: string, meta?: JsonHeader): Function;\nexport function Redirect(...args: any[]): Function {\n const {status, url, meta} = args.reduce(\n (options: any, value: any) => {\n if (isNumber(value)) {\n options.status = value;\n return options;\n }\n\n if (isString(value)) {\n options.url = value;\n return options;\n }\n\n options.meta = value;\n return options;\n },\n {status: 302, url: \"\", meta: {}}\n );\n return useDecorators(\n Returns(status).Location(url, meta),\n JsonEntityFn((entity) => {\n entity.operation?.setRedirection(status);\n })\n );\n}\n"]}
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { decorateMethodsOf, decoratorTypeOf, DecoratorTypes, isArray, isCollection, isObject, isPlainObject, isPrimitiveOrPrimitiveClass, isString } from "@tsed/core";
|
|
2
|
+
import { getStatusMessage } from "../../constants/httpStatusMessages.js";
|
|
3
|
+
import { DecoratorContext } from "../../domain/DecoratorContext.js";
|
|
4
|
+
import { JsonEntityStore } from "../../domain/JsonEntityStore.js";
|
|
5
|
+
import { JsonSchema } from "../../domain/JsonSchema.js";
|
|
6
|
+
import { getStatusModel } from "../../utils/defineStatusModel.js";
|
|
7
|
+
import { string } from "../../utils/from.js";
|
|
8
|
+
import { isSuccessStatus } from "../../utils/isSuccessStatus.js";
|
|
9
|
+
import { mapHeaders } from "../../utils/mapHeaders.js";
|
|
10
|
+
/**
|
|
11
|
+
* @ignore
|
|
12
|
+
*/
|
|
13
|
+
function isEnum(type) {
|
|
14
|
+
return isObject(type) && !("toJSON" in type);
|
|
15
|
+
}
|
|
16
|
+
function mapGenerics(types) {
|
|
17
|
+
return types.map((type) => {
|
|
18
|
+
if (isEnum(type)) {
|
|
19
|
+
return string().enum(Object.values(type));
|
|
20
|
+
}
|
|
21
|
+
return type;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* @ignore
|
|
26
|
+
*/
|
|
27
|
+
class ReturnDecoratorContext extends DecoratorContext {
|
|
28
|
+
constructor({ status, model }) {
|
|
29
|
+
super();
|
|
30
|
+
this.methods = [
|
|
31
|
+
"contentType",
|
|
32
|
+
"description",
|
|
33
|
+
"examples",
|
|
34
|
+
"type",
|
|
35
|
+
"status",
|
|
36
|
+
"of",
|
|
37
|
+
"oneOf",
|
|
38
|
+
"allOf",
|
|
39
|
+
"anyOf",
|
|
40
|
+
"nested",
|
|
41
|
+
"header",
|
|
42
|
+
"headers",
|
|
43
|
+
"schema",
|
|
44
|
+
"title",
|
|
45
|
+
"groups",
|
|
46
|
+
"location"
|
|
47
|
+
];
|
|
48
|
+
this.model(model);
|
|
49
|
+
this.status(status);
|
|
50
|
+
}
|
|
51
|
+
type(model) {
|
|
52
|
+
return this.model(model);
|
|
53
|
+
}
|
|
54
|
+
model(model) {
|
|
55
|
+
model && this.set("model", model);
|
|
56
|
+
return this;
|
|
57
|
+
}
|
|
58
|
+
status(status) {
|
|
59
|
+
this.set("status", status);
|
|
60
|
+
if (status && getStatusMessage(status) && !this.get("description")) {
|
|
61
|
+
this.set("description", getStatusMessage(status));
|
|
62
|
+
if (!this.get("model")) {
|
|
63
|
+
this.model(getStatusModel(+status));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return this;
|
|
67
|
+
}
|
|
68
|
+
headers(headers) {
|
|
69
|
+
this.set("headers", {
|
|
70
|
+
...(this.get("headers") || {}),
|
|
71
|
+
...mapHeaders(headers)
|
|
72
|
+
});
|
|
73
|
+
return this;
|
|
74
|
+
}
|
|
75
|
+
header(key, value) {
|
|
76
|
+
return this.headers({ [key]: value });
|
|
77
|
+
}
|
|
78
|
+
location(path, meta = {}) {
|
|
79
|
+
this.headers({
|
|
80
|
+
Location: {
|
|
81
|
+
...meta,
|
|
82
|
+
value: path
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
return this;
|
|
86
|
+
}
|
|
87
|
+
groups(...groups) {
|
|
88
|
+
this.set("groups", groups);
|
|
89
|
+
return this;
|
|
90
|
+
}
|
|
91
|
+
nested(...generics) {
|
|
92
|
+
const model = this.get("model");
|
|
93
|
+
this.checkPrimitive(model);
|
|
94
|
+
this.checkCollection(model);
|
|
95
|
+
this.addAction((ctx) => {
|
|
96
|
+
this.get("schema").nestedGenerics.push(mapGenerics(generics));
|
|
97
|
+
});
|
|
98
|
+
return this;
|
|
99
|
+
}
|
|
100
|
+
of(...types) {
|
|
101
|
+
const model = this.get("model");
|
|
102
|
+
this.checkPrimitive(model);
|
|
103
|
+
this.addAction(() => {
|
|
104
|
+
const schema = this.get("schema");
|
|
105
|
+
if (isCollection(model)) {
|
|
106
|
+
schema === null || schema === void 0 ? void 0 : schema.itemSchema({ type: types[0] });
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
schema === null || schema === void 0 ? void 0 : schema.nestedGenerics.push(mapGenerics(types));
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
return this;
|
|
113
|
+
}
|
|
114
|
+
oneOf(...types) {
|
|
115
|
+
const model = this.get("model");
|
|
116
|
+
this.addAction(() => {
|
|
117
|
+
const schema = this.get("schema");
|
|
118
|
+
schema.type(model);
|
|
119
|
+
schema.itemSchema({ oneOf: types.map((type) => ({ type })) });
|
|
120
|
+
});
|
|
121
|
+
return this;
|
|
122
|
+
}
|
|
123
|
+
allOf(...types) {
|
|
124
|
+
const model = this.get("model");
|
|
125
|
+
this.addAction(() => {
|
|
126
|
+
const schema = this.get("schema");
|
|
127
|
+
schema.type(model);
|
|
128
|
+
schema.itemSchema({ allOf: types.map((type) => ({ type })) });
|
|
129
|
+
});
|
|
130
|
+
return this;
|
|
131
|
+
}
|
|
132
|
+
anyOf(...types) {
|
|
133
|
+
const model = this.get("model");
|
|
134
|
+
this.addAction(() => {
|
|
135
|
+
const schema = this.get("schema");
|
|
136
|
+
schema.type(model);
|
|
137
|
+
schema.itemSchema({ anyOf: types.map((type) => ({ type })) });
|
|
138
|
+
});
|
|
139
|
+
return this;
|
|
140
|
+
}
|
|
141
|
+
schema(partial) {
|
|
142
|
+
this.addAction(() => {
|
|
143
|
+
const schema = this.get("schema");
|
|
144
|
+
schema.assign(partial);
|
|
145
|
+
});
|
|
146
|
+
return this;
|
|
147
|
+
}
|
|
148
|
+
examples(examples) {
|
|
149
|
+
this.set("examples", isString(examples) ? [examples] : examples);
|
|
150
|
+
return this;
|
|
151
|
+
}
|
|
152
|
+
title(title) {
|
|
153
|
+
return this.schema({ title });
|
|
154
|
+
}
|
|
155
|
+
checkPrimitive(model) {
|
|
156
|
+
if (isPrimitiveOrPrimitiveClass(model)) {
|
|
157
|
+
throw new Error("Returns.Of cannot be used with the following primitive classes: String, Number, Boolean");
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
checkCollection(model) {
|
|
161
|
+
if (isCollection(model)) {
|
|
162
|
+
throw new Error("Returns.Nested cannot be used with the following classes: Map, Set, Array, String, Number, Boolean");
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
getContentType() {
|
|
166
|
+
const model = this.get("model");
|
|
167
|
+
let contentType = this.get("contentType");
|
|
168
|
+
if (model && !isPlainObject(model) && !isPrimitiveOrPrimitiveClass(model)) {
|
|
169
|
+
contentType = contentType || "application/json";
|
|
170
|
+
}
|
|
171
|
+
return contentType;
|
|
172
|
+
}
|
|
173
|
+
getStatus() {
|
|
174
|
+
return this.get("status") || "default";
|
|
175
|
+
}
|
|
176
|
+
onInit(args, decorator) {
|
|
177
|
+
const type = decoratorTypeOf(args);
|
|
178
|
+
switch (type) {
|
|
179
|
+
case DecoratorTypes.METHOD:
|
|
180
|
+
this.entity = JsonEntityStore.from(...args);
|
|
181
|
+
if (this.entity.operation) {
|
|
182
|
+
this.map();
|
|
183
|
+
}
|
|
184
|
+
break;
|
|
185
|
+
case DecoratorTypes.CLASS:
|
|
186
|
+
this.decoratorType = DecoratorTypes.CLASS;
|
|
187
|
+
decorateMethodsOf(args[0], decorator);
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
map() {
|
|
192
|
+
const model = this.get("model");
|
|
193
|
+
const { entity, decoratorType } = this;
|
|
194
|
+
const operation = this.entity.operation;
|
|
195
|
+
const currentStatus = this.getStatus();
|
|
196
|
+
const response = operation.ensureResponseOf(currentStatus);
|
|
197
|
+
const contentType = this.getContentType();
|
|
198
|
+
let { description = response.get("description") } = this.toObject();
|
|
199
|
+
if (description) {
|
|
200
|
+
description = decoratorType === DecoratorTypes.CLASS ? response.get("description") || description : description;
|
|
201
|
+
response.description(description);
|
|
202
|
+
}
|
|
203
|
+
const headers = this.getMergedKey("headers", response.get("headers"));
|
|
204
|
+
if (headers) {
|
|
205
|
+
response.headers(headers);
|
|
206
|
+
}
|
|
207
|
+
this.mapMedia(response);
|
|
208
|
+
if (isSuccessStatus(this.get("status")) || currentStatus === "default") {
|
|
209
|
+
if (model) {
|
|
210
|
+
entity.type = model;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
// additional info for OS2
|
|
214
|
+
contentType && operation.addProduce(contentType);
|
|
215
|
+
// run additional actions
|
|
216
|
+
return this.runActions();
|
|
217
|
+
}
|
|
218
|
+
mapMedia(response) {
|
|
219
|
+
const contentType = this.getContentType();
|
|
220
|
+
const model = this.get("model");
|
|
221
|
+
const media = response.getMedia(contentType || "*/*");
|
|
222
|
+
const schema = media.get("schema") || new JsonSchema({ type: model });
|
|
223
|
+
if (model) {
|
|
224
|
+
if (isArray(model)) {
|
|
225
|
+
schema.oneOf(model.map((type) => ({ type })));
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
schema.type(model);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
this.set("schema", schema);
|
|
232
|
+
media.schema(schema);
|
|
233
|
+
media.groups = this.get("groups");
|
|
234
|
+
const examples = this.get("examples");
|
|
235
|
+
if (examples) {
|
|
236
|
+
media.examples(examples);
|
|
237
|
+
}
|
|
238
|
+
return media;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
export function Returns(status, model) {
|
|
242
|
+
const context = new ReturnDecoratorContext({
|
|
243
|
+
status,
|
|
244
|
+
model
|
|
245
|
+
});
|
|
246
|
+
return context.build();
|
|
247
|
+
}
|
|
248
|
+
//# sourceMappingURL=returns.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"returns.js","sourceRoot":"","sources":["../../../../src/decorators/operations/returns.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,eA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AE;gBAClB,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAC,IAAI,EAAC,CAAC,CAAC,CAAC,CAAC;aAC7C;iBAAM;gBACL,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aACpB;SACF;QAED,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAE3B,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAErB,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAElC,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QAEtC,IAAI,QAAQ,EAAE;YACZ,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;SAC1B;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AA+JD,MAAM,UAAU,OAAO,CAAC,MAAwB,EAAE,KAAqC;IACrF,MAAM,OAAO,GAAG,IAAI,sBAAsB,CAAC;QACzC,MAAM;QACN,KAAK;KACN,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC,KAAK,EAAE,CAAC;AACzB,CAAC","sourcesContent":["import {\n decorateMethodsOf,\n decoratorTypeOf,\n DecoratorTypes,\n isArray,\n isCollection,\n isObject,\n isPlainObject,\n isPrimitiveOrPrimitiveClass,\n isString,\n Type\n} from \"@tsed/core\";\nimport {OS3Example} from \"@tsed/openspec\";\nimport {getStatusMessage, HTTP_STATUS_MESSAGES} from \"../../constants/httpStatusMessages\";\nimport {DecoratorContext} from \"../../domain/DecoratorContext\";\nimport {JsonEntityStore} from \"../../domain/JsonEntityStore\";\nimport {JsonResponse} from \"../../domain/JsonResponse\";\nimport {JsonSchema, JsonSchemaObject} from \"../../domain/JsonSchema\";\nimport {JsonHeader, JsonHeaders} from \"../../interfaces/JsonOpenSpec\";\nimport {getStatusModel} from \"../../utils/defineStatusModel\";\nimport {string} from \"../../utils/from\";\nimport {GenericValue} from \"../../utils/generics\";\nimport {isSuccessStatus} from \"../../utils/isSuccessStatus\";\nimport {mapHeaders} from \"../../utils/mapHeaders\";\n\nexport interface ReturnsChainedDecorators {\n <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> | void;\n\n (target: Function): void;\n\n /**\n * Set a Content-Type for the current response\n * @param value\n * @constructor\n */\n ContentType(value: string): this;\n\n /**\n * Add a description\n * @param description\n */\n Description(description: string): this;\n\n /**\n * Add examples\n * @param examples\n */\n Examples(examples: Record<string, OS3Example>): this;\n\n Examples(examples: Record<string, any>): this;\n\n Examples(examples: any): this;\n\n /**\n * Change the model type\n * @param type\n */\n Type(type: Type<any> | any): this;\n\n /**\n * Change the status\n * @param status\n * @constructor\n */\n Status(status: string | number): this;\n\n /**\n * Add the nested types\n * @param types\n */\n Of(...types: GenericValue[]): this;\n\n /**\n * Add the nested types\n * @param types\n */\n OneOf(...types: GenericValue[]): this;\n\n /**\n * Add the nested types\n * @param types\n */\n AllOf(...types: GenericValue[]): this;\n\n /**\n * Add the nested types\n * @param types\n */\n AnyOf(...types: GenericValue[]): this;\n\n /**\n * Declare a nested generic models\n * @param generics\n */\n Nested(...generics: GenericValue[]): this;\n\n /**\n * Add header.\n * @param key\n * @param value\n */\n Header(key: string, value: number | string | (JsonHeader & {value?: string | number | boolean})): this;\n\n /**\n * Add headers\n */\n Headers(headers: JsonHeaders): this;\n\n /**\n * Add location hea\n */\n Location(location: string, meta?: JsonHeader): this;\n\n /**\n * Assign partial schema\n * @param schema\n */\n Schema(schema: Partial<JsonSchemaObject> | JsonSchema): this;\n\n /**\n * Add an inline title for the return model.\n * @param title\n */\n Title(title: string): this;\n\n /**\n *\n * @param groups\n * @constructor\n */\n Groups(...groups: string[]): this;\n\n [key: string]: any;\n}\n\n/**\n * @ignore\n */\nfunction isEnum(type: any) {\n return isObject(type) && !(\"toJSON\" in type);\n}\n\nfunction mapGenerics(types: GenericValue[]) {\n return types.map((type) => {\n if (isEnum(type)) {\n return string().enum(Object.values(type));\n }\n return type;\n });\n}\n\n/**\n * @ignore\n */\nclass ReturnDecoratorContext extends DecoratorContext<ReturnsChainedDecorators> {\n readonly methods: string[] = [\n \"contentType\",\n \"description\",\n \"examples\",\n \"type\",\n \"status\",\n \"of\",\n \"oneOf\",\n \"allOf\",\n \"anyOf\",\n \"nested\",\n \"header\",\n \"headers\",\n \"schema\",\n \"title\",\n \"groups\",\n \"location\"\n ];\n\n constructor({status, model}: any) {\n super();\n\n this.model(model);\n this.status(status);\n }\n\n type(model: any) {\n return this.model(model);\n }\n\n model(model: any) {\n model && this.set(\"model\", model);\n return this;\n }\n\n status(status: number | string) {\n this.set(\"status\", status);\n\n if (status && getStatusMessage(status) && !this.get(\"description\")) {\n this.set(\"description\", getStatusMessage(status));\n\n if (!this.get(\"model\")) {\n this.model(getStatusModel(+status));\n }\n }\n\n return this;\n }\n\n headers(headers: JsonHeaders) {\n this.set(\"headers\", {\n ...(this.get(\"headers\") || {}),\n ...mapHeaders(headers)\n });\n\n return this;\n }\n\n header(key: string, value: string | JsonHeader) {\n return this.headers({[key]: value});\n }\n\n location(path: string, meta: JsonHeaders = {}) {\n this.headers({\n Location: {\n ...meta,\n value: path\n }\n });\n\n return this;\n }\n\n groups(...groups: string[]) {\n this.set(\"groups\", groups);\n return this;\n }\n\n nested(...generics: GenericValue[]) {\n const model = this.get(\"model\");\n this.checkPrimitive(model);\n this.checkCollection(model);\n\n this.addAction((ctx) => {\n (this.get(\"schema\") as JsonSchema).nestedGenerics.push(mapGenerics(generics));\n });\n\n return this;\n }\n\n of(...types: (Type<any> | any)[]) {\n const model = this.get(\"model\");\n this.checkPrimitive(model);\n\n this.addAction(() => {\n const schema = this.get(\"schema\") as JsonSchema;\n\n if (isCollection(model)) {\n schema?.itemSchema({type: types[0]});\n } else {\n schema?.nestedGenerics.push(mapGenerics(types));\n }\n });\n\n return this;\n }\n\n oneOf(...types: (Type<any> | any)[]) {\n const model = this.get(\"model\");\n\n this.addAction(() => {\n const schema = this.get(\"schema\") as JsonSchema;\n schema.type(model);\n schema.itemSchema({oneOf: types.map((type) => ({type}))});\n });\n\n return this;\n }\n\n allOf(...types: (Type<any> | any)[]) {\n const model = this.get(\"model\");\n\n this.addAction(() => {\n const schema = this.get(\"schema\") as JsonSchema;\n schema.type(model);\n schema.itemSchema({allOf: types.map((type) => ({type}))});\n });\n\n return this;\n }\n\n anyOf(...types: (Type<any> | any)[]) {\n const model = this.get(\"model\");\n\n this.addAction(() => {\n const schema = this.get(\"schema\") as JsonSchema;\n schema.type(model);\n schema.itemSchema({anyOf: types.map((type) => ({type}))});\n });\n\n return this;\n }\n\n schema(partial: Partial<JsonSchemaObject>) {\n this.addAction(() => {\n const schema = this.get(\"schema\") as JsonSchema;\n\n schema!.assign(partial);\n });\n\n return this;\n }\n\n examples(examples: any) {\n this.set(\"examples\", isString(examples) ? [examples] : examples);\n return this;\n }\n\n title(title: string) {\n return this.schema({title});\n }\n\n protected checkPrimitive(model: any) {\n if (isPrimitiveOrPrimitiveClass(model)) {\n throw new Error(\"Returns.Of cannot be used with the following primitive classes: String, Number, Boolean\");\n }\n }\n\n protected checkCollection(model: any) {\n if (isCollection(model)) {\n throw new Error(\"Returns.Nested cannot be used with the following classes: Map, Set, Array, String, Number, Boolean\");\n }\n }\n\n protected getContentType() {\n const model = this.get(\"model\");\n let contentType = this.get(\"contentType\");\n\n if (model && !isPlainObject(model) && !isPrimitiveOrPrimitiveClass(model)) {\n contentType = contentType || \"application/json\";\n }\n\n return contentType;\n }\n\n protected getStatus() {\n return this.get(\"status\") || \"default\";\n }\n\n protected onInit(args: any[], decorator: any) {\n const type = decoratorTypeOf(args);\n switch (type) {\n case DecoratorTypes.METHOD:\n this.entity = JsonEntityStore.from(...args);\n if (this.entity.operation) {\n this.map();\n }\n break;\n case DecoratorTypes.CLASS:\n this.decoratorType = DecoratorTypes.CLASS;\n decorateMethodsOf(args[0], decorator);\n break;\n }\n }\n\n protected map() {\n const model = this.get(\"model\");\n const {entity, decoratorType} = this;\n const operation = this.entity.operation!;\n const currentStatus = this.getStatus();\n const response = operation.ensureResponseOf(currentStatus);\n const contentType = this.getContentType();\n\n let {description = response.get(\"description\")} = this.toObject();\n\n if (description) {\n description = decoratorType === DecoratorTypes.CLASS ? response.get(\"description\") || description : description;\n response.description(description);\n }\n\n const headers = this.getMergedKey(\"headers\", response.get(\"headers\"));\n\n if (headers) {\n response.headers(headers);\n }\n\n this.mapMedia(response);\n\n if (isSuccessStatus(this.get(\"status\")) || currentStatus === \"default\") {\n if (model) {\n entity.type = model;\n }\n }\n\n // additional info for OS2\n contentType && operation.addProduce(contentType);\n\n // run additional actions\n return this.runActions();\n }\n\n protected mapMedia(response: JsonResponse) {\n const contentType = this.getContentType();\n const model = this.get(\"model\");\n const media = response.getMedia(contentType || \"*/*\");\n const schema = media.get(\"schema\") || new JsonSchema({type: model});\n\n if (model) {\n if (isArray(model)) {\n schema.oneOf(model.map((type) => ({type})));\n } else {\n schema.type(model);\n }\n }\n\n this.set(\"schema\", schema);\n\n media.schema(schema);\n\n media.groups = this.get(\"groups\");\n\n const examples = this.get(\"examples\");\n\n if (examples) {\n media.examples(examples);\n }\n\n return media;\n }\n}\n\n/**\n * Add responses documentation for a specific status code.\n *\n * ## Usage\n *\n * Ts.ED v5/v6 API introducing the chaining decorator concept. Now a decorator like Returns can be used with another decorators like Description.\n *\n * ::: warning\n * v5 has a basic support of the chaining decorator to facilitate the migration to v6!\n * :::\n *\n * ```typescript\n * import {Returns} from \"@tsed/schema\";\n *\n * @Controller(\"/\")\n * class MyController {\n * @Returns(404, String).Description(\"Not Found\")\n * @Returns(200, Model).Description(\"Success\")\n * async myMethod(): Promise<Model> {}\n * }\n * ```\n *\n * ::: tip\n * TypeScript and your IDE will discover automatically the chained decorators. But for more details you can look on @@ReturnsChainedDecorators@@ interface, to know\n * what chained decorators are available under Returns decorator.\n * :::\n *\n * This example will produce this documentation in swagger:\n *\n * ```json\n * {\n * \"responses\": {\n * \"404\": {\n * \"description\": \"Description\",\n * \"schema\": {\"type\": \"string\"}\n * },\n * \"2OO\": {\n * \"description\": \"Description\",\n * \"schema\": {\"$ref\": \"...\"}\n * }\n * }\n * }\n * ```\n *\n * ## Declaring an Array\n *\n * Use chained decorators to declare an array with model as following:\n *\n * ```typescript\n * import {Returns} from \"@tsed/schema\";\n *\n * @Controller(\"/models\")\n * class ModelCtrl {\n * @Get(\"/\")\n * @Returns(200, Array).Of(Model).Description(\"Success\")\n * async myMethod(): Promise<Model> {\n * }\n * }\n * ```\n *\n * Deprecated version:\n *\n * ```typescript\n * import {ReturnsArray} from \"@tsed/common\";\n * import {Returns} from \"@tsed/schema\";\n *\n * @Controller(\"/\")\n * class MyController {\n * @ReturnsArray(200, Model) // deprecated\n * async myMethod(): Promise<Model> {}\n * }\n * ```\n *\n * ### Declaring a generic model <Badge text=\"6+\"/>\n *\n * Sometime, it might be useful to use generic models. TypeScript doesn't store the generic type in the metadata. This is why we need to\n * declare explicitly the generic models with the decorators.\n *\n * One of the generic's usage, can be a paginated list. With Returns decorator it's now possible to declare generic type and generate the appropriate OpenSpec documentation.\n *\n * Starting with the pagination model, by using @@Generics@@ and @@CollectionOf@@:\n *\n * ```typescript\n * @Generics(\"T\")\n * class Pagination<T> {\n * @CollectionOf(\"T\")\n * data: T[];\n *\n * @Property()\n * totalCount: number;\n * }\n * ```\n *\n * Now, we need a model to be used with the generic Pagination model:\n *\n * ```typescript\n * class Product {\n * @Property()\n * id: string;\n *\n * @Property()\n * title: string;\n * }\n * ```\n *\n * Finally, we can use our models on a method as following:\n *\n * ```typescript\n * class Controller {\n * @OperationPath(\"POST\", \"/\")\n * @Returns(200, Pagination).Of(Product).Description(\"description\")\n * async method(): Promise<Pagination<Product> | null> {\n * return null;\n * }\n * }\n * ```\n *\n * ### Declaring a nested generics models <Badge text=\"6+\"/>\n *\n * It's also possible to declare a nested generics models in order to have this type `Pagination<Submission<Product>>`:\n *\n * ```typescript\n * import {Generics, Property, Returns} from \"@tsed/schema\";\n * import {Post} from \"@tsed/common\";\n *\n * class Controller {\n * @Post(\"/\")\n * @Returns(200, Pagination).Of(Submission).Nested(Product).Description(\"description\")\n * async method(): Promise<Pagination<Submission<Product>> | null> {\n * return null;\n * }\n * }\n * ```\n *\n * And here is the Submission model:\n *\n * ```typescript\n * import {Generics, Property} from \"@tsed/schema\";\n *\n * @Generics(\"T\")\n * class Submission<T> {\n * @Property()\n * _id: string;\n * @Property(\"T\")\n * data: T;\n * }\n * ```\n *\n * @param status\n * @param model\n * @decorator\n * @swagger\n * @schema\n * @response\n * @operation\n */\nexport function Returns(status?: string | number, model?: Type<any> | Type<any>[]): ReturnsChainedDecorators;\nexport function Returns(status?: string | number, model?: Type<any> | Type<any>[] | any): ReturnsChainedDecorators {\n const context = new ReturnDecoratorContext({\n status,\n model\n });\n\n return context.build();\n}\n"]}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { DecoratorContext } from "../../domain/DecoratorContext.js";
|
|
2
|
+
import { mapRouteOptions } from "../../utils/mapRouteOptions.js";
|
|
3
|
+
import { OperationMethods } from "../../constants/httpMethods.js";
|
|
4
|
+
class RouteDecoratorContext extends DecoratorContext {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(...arguments);
|
|
7
|
+
this.methods = ["name", "description", "summary", "method", "id", "use", "useAfter", "useBefore"];
|
|
8
|
+
}
|
|
9
|
+
beforeInit() {
|
|
10
|
+
const path = this.get("path");
|
|
11
|
+
const method = OperationMethods[this.get("method")] || OperationMethods.CUSTOM;
|
|
12
|
+
path && this.entity.operation.addOperationPath(method, path);
|
|
13
|
+
}
|
|
14
|
+
onMapKey(key, value) {
|
|
15
|
+
switch (key) {
|
|
16
|
+
case "name":
|
|
17
|
+
case "id":
|
|
18
|
+
this.entity.operation.operationId(value);
|
|
19
|
+
return;
|
|
20
|
+
case "summary":
|
|
21
|
+
this.entity.operation.summary(value);
|
|
22
|
+
return;
|
|
23
|
+
case "description":
|
|
24
|
+
this.entity.operation.description(value);
|
|
25
|
+
return;
|
|
26
|
+
case "use":
|
|
27
|
+
this.entity.use(value);
|
|
28
|
+
return;
|
|
29
|
+
case "useAfter":
|
|
30
|
+
this.entity.after(value);
|
|
31
|
+
return;
|
|
32
|
+
case "useBefore":
|
|
33
|
+
this.entity.before(value);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
return super.onMapKey(key, value);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export function Route(...args) {
|
|
40
|
+
const routeOptions = mapRouteOptions(args);
|
|
41
|
+
const context = new RouteDecoratorContext(routeOptions);
|
|
42
|
+
return context.build();
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).
|
|
46
|
+
*
|
|
47
|
+
* This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.
|
|
48
|
+
* For example, if you placed the following route at the top of all other route definitions, it would require that
|
|
49
|
+
* all routes from that point on would require authentication, and automatically load a user.
|
|
50
|
+
* Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()
|
|
51
|
+
* to continue matching subsequent routes.
|
|
52
|
+
* @param path
|
|
53
|
+
* @param args
|
|
54
|
+
* @returns {Function}
|
|
55
|
+
* @decorator
|
|
56
|
+
* @operation
|
|
57
|
+
* @httpMethod
|
|
58
|
+
*/
|
|
59
|
+
export function All(path = "/", ...args) {
|
|
60
|
+
return Route(...[OperationMethods.ALL, path].concat(args));
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).
|
|
64
|
+
*
|
|
65
|
+
* This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.
|
|
66
|
+
* For example, if you placed the following route at the top of all other route definitions, it would require that
|
|
67
|
+
* all routes from that point on would require authentication, and automatically load a user.
|
|
68
|
+
* Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()
|
|
69
|
+
* to continue matching subsequent routes.
|
|
70
|
+
* @param path
|
|
71
|
+
* @param args
|
|
72
|
+
* @returns {Function}
|
|
73
|
+
* @decorator
|
|
74
|
+
* @operation
|
|
75
|
+
* @httpMethod
|
|
76
|
+
*/
|
|
77
|
+
export function Get(path = "/", ...args) {
|
|
78
|
+
return Route(...[OperationMethods.GET, path].concat(args));
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).
|
|
82
|
+
*
|
|
83
|
+
* This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.
|
|
84
|
+
* For example, if you placed the following route at the top of all other route definitions, it would require that
|
|
85
|
+
* all routes from that point on would require authentication, and automatically load a user.
|
|
86
|
+
* Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()
|
|
87
|
+
* to continue matching subsequent routes.
|
|
88
|
+
* @param path
|
|
89
|
+
* @param args
|
|
90
|
+
* @returns {Function}
|
|
91
|
+
* @decorator
|
|
92
|
+
* @operation
|
|
93
|
+
* @httpMethod
|
|
94
|
+
*/
|
|
95
|
+
export function Post(path = "/", ...args) {
|
|
96
|
+
return Route(...[OperationMethods.POST, path].concat(args));
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).
|
|
100
|
+
*
|
|
101
|
+
* This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.
|
|
102
|
+
* For example, if you placed the following route at the top of all other route definitions, it would require that
|
|
103
|
+
* all routes from that point on would require authentication, and automatically load a user.
|
|
104
|
+
* Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()
|
|
105
|
+
* to continue matching subsequent routes.
|
|
106
|
+
* @param path
|
|
107
|
+
* @param args
|
|
108
|
+
* @returns {Function}
|
|
109
|
+
* @decorator
|
|
110
|
+
* @operation
|
|
111
|
+
* @httpMethod
|
|
112
|
+
*/
|
|
113
|
+
export function Put(path = "/", ...args) {
|
|
114
|
+
return Route(...[OperationMethods.PUT, path].concat(args));
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).
|
|
118
|
+
*
|
|
119
|
+
* This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.
|
|
120
|
+
* For example, if you placed the following route at the top of all other route definitions, it would require that
|
|
121
|
+
* all routes from that point on would require authentication, and automatically load a user.
|
|
122
|
+
* Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()
|
|
123
|
+
* to continue matching subsequent routes.
|
|
124
|
+
* @param path
|
|
125
|
+
* @param args
|
|
126
|
+
* @returns {Function}
|
|
127
|
+
* @decorator
|
|
128
|
+
* @operation
|
|
129
|
+
* @httpMethod
|
|
130
|
+
*/
|
|
131
|
+
export function Delete(path = "/", ...args) {
|
|
132
|
+
return Route(...[OperationMethods.DELETE, path].concat(args));
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).
|
|
136
|
+
*
|
|
137
|
+
* This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.
|
|
138
|
+
* For example, if you placed the following route at the top of all other route definitions, it would require that
|
|
139
|
+
* all routes from that point on would require authentication, and automatically load a user.
|
|
140
|
+
* Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()
|
|
141
|
+
* to continue matching subsequent routes.
|
|
142
|
+
* @param path
|
|
143
|
+
* @param args
|
|
144
|
+
* @returns {Function}
|
|
145
|
+
* @decorator
|
|
146
|
+
* @operation
|
|
147
|
+
* @httpMethod
|
|
148
|
+
*/
|
|
149
|
+
export function Head(path = "/", ...args) {
|
|
150
|
+
return Route(...[OperationMethods.HEAD, path].concat(args));
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).
|
|
154
|
+
*
|
|
155
|
+
* This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.
|
|
156
|
+
* For example, if you placed the following route at the top of all other route definitions, it would require that
|
|
157
|
+
* all routes from that point on would require authentication, and automatically load a user.
|
|
158
|
+
* Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()
|
|
159
|
+
* to continue matching subsequent routes.
|
|
160
|
+
* @param path
|
|
161
|
+
* @param args
|
|
162
|
+
* @returns {Function}
|
|
163
|
+
* @decorator
|
|
164
|
+
* @operation
|
|
165
|
+
* @httpMethod
|
|
166
|
+
*/
|
|
167
|
+
export function Patch(path = "/", ...args) {
|
|
168
|
+
return Route(...[OperationMethods.PATCH, path].concat(args));
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).
|
|
172
|
+
*
|
|
173
|
+
* This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.
|
|
174
|
+
* For example, if you placed the following route at the top of all other route definitions, it would require that
|
|
175
|
+
* all routes from that point on would require authentication, and automatically load a user.
|
|
176
|
+
* Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()
|
|
177
|
+
* to continue matching subsequent routes.
|
|
178
|
+
* @param path
|
|
179
|
+
* @param args
|
|
180
|
+
* @returns {Function}
|
|
181
|
+
* @decorator
|
|
182
|
+
* @operation
|
|
183
|
+
* @httpMethod
|
|
184
|
+
*/
|
|
185
|
+
export function Options(path = "/", ...args) {
|
|
186
|
+
return Route(...[OperationMethods.OPTIONS, path].concat(args));
|
|
187
|
+
}
|
|
188
|
+
//# sourceMappingURL=route.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route.js","sourceRoot":"","sources":["../../../../src/decorators/operations/route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAC,MAAM,+BAA+B,CAAC;AAC/D,OAA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AAU,MAAM,CAAC,OAA8B,GAAG,EAAE,GAAG,IAAW;IACtE,OAAO,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AAChE,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,IAAI,CAAC,OAA8B,GAAG,EAAE,GAAG,IAAW;IACpE,OAAO,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AAC9D,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,KAAK,CAAC,OAA8B,GAAG,EAAE,GAAG,IAAW;IACrE,OAAO,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AAC/D,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,OAAO,CAAC,OAA8B,GAAG,EAAE,GAAG,IAAW;IACvE,OAAO,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AACjE,CAAC","sourcesContent":["import {DecoratorContext} from \"../../domain/DecoratorContext\";\nimport {mapRouteOptions} from \"../../utils/mapRouteOptions\";\nimport {OperationMethods} from \"../../constants/httpMethods\";\nimport {JsonMethodStore} from \"../../domain/JsonMethodStore\";\n\nexport interface RouteChainedDecorators {\n <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> | void;\n\n /**\n * @param string\n * @constructor\n */\n Path(string: string): this;\n\n /**\n * Set the operation method\n * @param method\n */\n Method(method: OperationMethods | string): this;\n\n /**\n * Set the operation id\n * @param id\n */\n Id(id: string): this;\n\n /**\n * Set the operation id\n * @param name\n */\n Name(name: string): this;\n\n /**\n *\n * @param description\n */\n Description(description: string): this;\n\n /**\n * Summary\n * @constructor\n * @param Summary\n */\n Summary(Summary: string): this;\n\n Use(...args: any[]): this;\n\n UseAfter(...args: any[]): this;\n\n UseBefore(...args: any[]): this;\n}\n\nclass RouteDecoratorContext extends DecoratorContext<RouteChainedDecorators> {\n readonly methods: string[] = [\"name\", \"description\", \"summary\", \"method\", \"id\", \"use\", \"useAfter\", \"useBefore\"];\n protected entity: JsonMethodStore;\n\n protected beforeInit() {\n const path: string = this.get(\"path\");\n const method: string = OperationMethods[this.get(\"method\") as OperationMethods] || OperationMethods.CUSTOM;\n\n path && this.entity.operation.addOperationPath(method, path);\n }\n\n protected onMapKey(key: string, value: any) {\n switch (key) {\n case \"name\":\n case \"id\":\n this.entity.operation.operationId(value);\n return;\n case \"summary\":\n this.entity.operation.summary(value);\n return;\n case \"description\":\n this.entity.operation.description(value);\n return;\n case \"use\":\n this.entity.use(value);\n return;\n case \"useAfter\":\n this.entity.after(value);\n return;\n case \"useBefore\":\n this.entity.before(value);\n return;\n }\n\n return super.onMapKey(key, value);\n }\n}\n\n/**\n * Describe a new route with a method and path.\n *\n * ```typescript\n * @Controller('/')\n * export class Ctrl {\n *\n * @Route('GET', '/')\n * get() { }\n * }\n *\n * ```\n *\n * @returns {Function}\n * @param method\n * @param path\n * @param args\n * @decorator\n * @operation\n */\nexport function Route(method: string, path: string, ...args: any[]): RouteChainedDecorators;\nexport function Route(...args: any[]): RouteChainedDecorators;\nexport function Route(...args: any[]): RouteChainedDecorators {\n const routeOptions = mapRouteOptions(args);\n\n const context = new RouteDecoratorContext(routeOptions);\n\n return context.build();\n}\n\n/**\n * This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).\n *\n * This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.\n * For example, if you placed the following route at the top of all other route definitions, it would require that\n * all routes from that point on would require authentication, and automatically load a user.\n * Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()\n * to continue matching subsequent routes.\n * @param path\n * @param args\n * @returns {Function}\n * @decorator\n * @operation\n * @httpMethod\n */\nexport function All(path: string | RegExp | any = \"/\", ...args: any[]) {\n return Route(...[OperationMethods.ALL, path].concat(args));\n}\n\n/**\n * This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).\n *\n * This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.\n * For example, if you placed the following route at the top of all other route definitions, it would require that\n * all routes from that point on would require authentication, and automatically load a user.\n * Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()\n * to continue matching subsequent routes.\n * @param path\n * @param args\n * @returns {Function}\n * @decorator\n * @operation\n * @httpMethod\n */\nexport function Get(path: string | RegExp | any = \"/\", ...args: any[]) {\n return Route(...[OperationMethods.GET, path].concat(args));\n}\n\n/**\n * This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).\n *\n * This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.\n * For example, if you placed the following route at the top of all other route definitions, it would require that\n * all routes from that point on would require authentication, and automatically load a user.\n * Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()\n * to continue matching subsequent routes.\n * @param path\n * @param args\n * @returns {Function}\n * @decorator\n * @operation\n * @httpMethod\n */\nexport function Post(path: string | RegExp | any = \"/\", ...args: any[]) {\n return Route(...[OperationMethods.POST, path].concat(args));\n}\n\n/**\n * This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).\n *\n * This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.\n * For example, if you placed the following route at the top of all other route definitions, it would require that\n * all routes from that point on would require authentication, and automatically load a user.\n * Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()\n * to continue matching subsequent routes.\n * @param path\n * @param args\n * @returns {Function}\n * @decorator\n * @operation\n * @httpMethod\n */\nexport function Put(path: string | RegExp | any = \"/\", ...args: any[]) {\n return Route(...[OperationMethods.PUT, path].concat(args));\n}\n\n/**\n * This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).\n *\n * This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.\n * For example, if you placed the following route at the top of all other route definitions, it would require that\n * all routes from that point on would require authentication, and automatically load a user.\n * Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()\n * to continue matching subsequent routes.\n * @param path\n * @param args\n * @returns {Function}\n * @decorator\n * @operation\n * @httpMethod\n */\nexport function Delete(path: string | RegExp | any = \"/\", ...args: any[]) {\n return Route(...[OperationMethods.DELETE, path].concat(args));\n}\n\n/**\n * This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).\n *\n * This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.\n * For example, if you placed the following route at the top of all other route definitions, it would require that\n * all routes from that point on would require authentication, and automatically load a user.\n * Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()\n * to continue matching subsequent routes.\n * @param path\n * @param args\n * @returns {Function}\n * @decorator\n * @operation\n * @httpMethod\n */\nexport function Head(path: string | RegExp | any = \"/\", ...args: any[]) {\n return Route(...[OperationMethods.HEAD, path].concat(args));\n}\n\n/**\n * This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).\n *\n * This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.\n * For example, if you placed the following route at the top of all other route definitions, it would require that\n * all routes from that point on would require authentication, and automatically load a user.\n * Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()\n * to continue matching subsequent routes.\n * @param path\n * @param args\n * @returns {Function}\n * @decorator\n * @operation\n * @httpMethod\n */\nexport function Patch(path: string | RegExp | any = \"/\", ...args: any[]) {\n return Route(...[OperationMethods.PATCH, path].concat(args));\n}\n\n/**\n * This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).\n *\n * This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.\n * For example, if you placed the following route at the top of all other route definitions, it would require that\n * all routes from that point on would require authentication, and automatically load a user.\n * Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()\n * to continue matching subsequent routes.\n * @param path\n * @param args\n * @returns {Function}\n * @decorator\n * @operation\n * @httpMethod\n */\nexport function Options(path: string | RegExp | any = \"/\", ...args: any[]) {\n return Route(...[OperationMethods.OPTIONS, path].concat(args));\n}\n"]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { decorateMethodsOf, DecoratorTypes, UnsupportedDecoratorType } from "@tsed/core";
|
|
2
|
+
import { JsonEntityFn } from "../common/jsonEntityFn.js";
|
|
3
|
+
/**
|
|
4
|
+
* Add security metadata on the decorated method.
|
|
5
|
+
*
|
|
6
|
+
* ## Examples
|
|
7
|
+
* ### On method
|
|
8
|
+
*
|
|
9
|
+
* ```typescript
|
|
10
|
+
* @Controller("/")
|
|
11
|
+
* class ModelCtrl {
|
|
12
|
+
* @Security("write:calendars")
|
|
13
|
+
* async method() {}
|
|
14
|
+
* }
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* @param name
|
|
18
|
+
* @param scopes
|
|
19
|
+
* @decorator
|
|
20
|
+
* @swagger
|
|
21
|
+
* @schema
|
|
22
|
+
* @classDecorator
|
|
23
|
+
* @operation
|
|
24
|
+
*/
|
|
25
|
+
export function Security(name, ...scopes) {
|
|
26
|
+
return JsonEntityFn((store, args) => {
|
|
27
|
+
switch (store.decoratorType) {
|
|
28
|
+
case DecoratorTypes.METHOD:
|
|
29
|
+
store.operation.addSecurityScopes(name, scopes);
|
|
30
|
+
break;
|
|
31
|
+
case DecoratorTypes.CLASS:
|
|
32
|
+
decorateMethodsOf(args[0], Security(name, ...scopes));
|
|
33
|
+
break;
|
|
34
|
+
default:
|
|
35
|
+
throw new UnsupportedDecoratorType(Security, args);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=security.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security.js","sourceRoot":"","sources":["../../../../src/decorators/operations/security.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAE,cAAc,EAAE,wBAAwB,EAAC,MAAM,YAAY,CAAC;AACvF,OAAO,EAAC,YAAY,EAAC,MAAM,wBAAwB,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAY,EAAE,GAAG,MAAgB;IACxD,OAAO,YAAY,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;QAClC,QAAQ,KAAK,CAAC,aAAa,EAAE;YAC3B,KAAK,cAAc,CAAC,MAAM;gBACxB,KAAK,CAAC,SAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;gBACjD,MAAM;YACR,KAAK,cAAc,CAAC,KAAK;gBACvB,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,IAAI,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC;gBACtD,MAAM;YAER;gBACE,MAAM,IAAI,wBAAwB,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;SACtD;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {decorateMethodsOf, DecoratorTypes, UnsupportedDecoratorType} from \"@tsed/core\";\nimport {JsonEntityFn} from \"../common/jsonEntityFn\";\n\n/**\n * Add security metadata on the decorated method.\n *\n * ## Examples\n * ### On method\n *\n * ```typescript\n * @Controller(\"/\")\n * class ModelCtrl {\n * @Security(\"write:calendars\")\n * async method() {}\n * }\n * ```\n *\n * @param name\n * @param scopes\n * @decorator\n * @swagger\n * @schema\n * @classDecorator\n * @operation\n */\nexport function Security(name: string, ...scopes: string[]) {\n return JsonEntityFn((store, args) => {\n switch (store.decoratorType) {\n case DecoratorTypes.METHOD:\n store.operation!.addSecurityScopes(name, scopes);\n break;\n case DecoratorTypes.CLASS:\n decorateMethodsOf(args[0], Security(name, ...scopes));\n break;\n\n default:\n throw new UnsupportedDecoratorType(Security, args);\n }\n });\n}\n"]}
|