@tsed/schema 6.96.1 → 6.97.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/jest.config.js +14 -0
  2. package/lib/cjs/components/objectMapper.js +6 -3
  3. package/lib/cjs/components/objectMapper.js.map +1 -1
  4. package/lib/cjs/components/schemaMapper.js +1 -1
  5. package/lib/cjs/components/schemaMapper.js.map +1 -1
  6. package/lib/cjs/domain/JsonOperation.js +5 -9
  7. package/lib/cjs/domain/JsonOperation.js.map +1 -1
  8. package/lib/cjs/domain/JsonSchema.js +78 -60
  9. package/lib/cjs/domain/JsonSchema.js.map +1 -1
  10. package/lib/cjs/domain/SpecTypes.js +3 -0
  11. package/lib/cjs/domain/SpecTypes.js.map +1 -1
  12. package/lib/cjs/utils/getSpec.js +3 -3
  13. package/lib/cjs/utils/getSpec.js.map +1 -1
  14. package/lib/cjs/utils/mapNullableType.js +30 -11
  15. package/lib/cjs/utils/mapNullableType.js.map +1 -1
  16. package/lib/cjs/utils/ref.js +13 -10
  17. package/lib/cjs/utils/ref.js.map +1 -1
  18. package/lib/esm/components/objectMapper.js +6 -3
  19. package/lib/esm/components/objectMapper.js.map +1 -1
  20. package/lib/esm/components/schemaMapper.js +1 -1
  21. package/lib/esm/components/schemaMapper.js.map +1 -1
  22. package/lib/esm/domain/JsonOperation.js +5 -9
  23. package/lib/esm/domain/JsonOperation.js.map +1 -1
  24. package/lib/esm/domain/JsonSchema.js +78 -60
  25. package/lib/esm/domain/JsonSchema.js.map +1 -1
  26. package/lib/esm/domain/SpecTypes.js +3 -0
  27. package/lib/esm/domain/SpecTypes.js.map +1 -1
  28. package/lib/esm/utils/getSpec.js +3 -3
  29. package/lib/esm/utils/getSpec.js.map +1 -1
  30. package/lib/esm/utils/mapNullableType.js +31 -12
  31. package/lib/esm/utils/mapNullableType.js.map +1 -1
  32. package/lib/esm/utils/ref.js +13 -10
  33. package/lib/esm/utils/ref.js.map +1 -1
  34. package/lib/types/domain/JsonSchema.d.ts +5 -11
  35. package/lib/types/domain/SpecTypes.d.ts +3 -0
  36. package/package.json +6 -6
  37. package/.mocharc.js +0 -5
  38. package/.nycrc +0 -27
  39. package/lib/cjs/utils/isJsonClass.js +0 -12
  40. package/lib/cjs/utils/isJsonClass.js.map +0 -1
  41. package/lib/esm/utils/isJsonClass.js +0 -8
  42. package/lib/esm/utils/isJsonClass.js.map +0 -1
  43. package/lib/types/utils/isJsonClass.d.ts +0 -4
@@ -1 +1 @@
1
- {"version":3,"file":"JsonSchema.js","sourceRoot":"","sources":["../../../src/domain/JsonSchema.ts"],"names":[],"mappings":";;;AAAA,qCAA+G;AAI/G,uFAAmE;AAEnE,8DAAyD;AACzD,sDAAiD;AACjD,sDAAiD;AAIjD,uDAAkD;AAWlD,SAAS,aAAa,CAAC,UAA+B;IACpD,uBAAuB;IACvB,IAAI,UAAU,YAAY,UAAU,EAAE;QACpC,OAAO,UAAU,CAAC;KACnB;IAED,OAAO,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,MAAM,CAAM,CAAC,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,EAAE;QAC1E,UAAU,CAAC,IAAA,yBAAW,EAAC,GAAG,CAAC,CAAC,GAAG,IAAA,cAAO,EAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;QAEvG,OAAO,UAAU,CAAC;IACpB,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC;AAED,SAAS,eAAe,CAAC,IAAS;IAChC,IAAI,IAAA,cAAO,EAAC,IAAI,CAAC,EAAE;QACjB,OAAQ,IAAc,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;KAC7C;IAED,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,SAAS,EAAE;QACvD,O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AAO,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;CACF;AAj0BD,gCAi0BC","sourcesContent":["import {classOf, Hooks, isArray, isClass, isFunction, isObject, nameOf, Type, uniq, ValueOf} from \"@tsed/core\";\nimport type {JSONSchema6, JSONSchema6Definition, JSONSchema6Type, JSONSchema6TypeName, JSONSchema6Version} from \"json-schema\";\nimport {JsonSchemaOptions} from \"../interfaces\";\nimport {IgnoreCallback} from \"../interfaces/IgnoreCallback\";\nimport {execMapper} from \"../registries/JsonSchemaMapperContainer\";\nimport {NestedGenerics} from \"../utils/generics\";\nimport {getComputedType} from \"../utils/getComputedType\";\nimport {getJsonType} from \"../utils/getJsonType\";\nimport {toJsonRegex} from \"../utils/toJsonRegex\";\nimport {AliasMap, AliasType} from \"./JsonAliasMap\";\nimport {JsonFormatTypes} from \"./JsonFormatTypes\";\nimport {JsonLazyRef} from \"./JsonLazyRef\";\nimport {JsonEntityStore} from \"./JsonEntityStore\";\n\nexport interface JsonSchemaObject extends JSONSchema6, Record<string, any> {\n type: (any | JSONSchema6TypeName) | (any | JSONSchema6TypeName)[];\n additionalProperties?: boolean | JSONSchema6 | any;\n propertyNames?: boolean | JSONSchema6 | any;\n items?: (any | JSONSchema6Definition) | (any | JSONSchema6Definition)[];\n}\n\nexport type AnyJsonSchema = Partial<JsonSchemaObject> | JsonSchema | JsonLazyRef | any;\n\nfunction mapProperties(properties: Record<string, any>) {\n // istanbul ignore next\n if (properties instanceof JsonSchema) {\n return properties;\n }\n\n return Object.entries(properties).reduce<any>((properties, [key, schema]) => {\n properties[toJsonRegex(key)] = isArray(schema) ? schema.map(mapToJsonSchema) : mapToJsonSchema(schema);\n\n return properties;\n }, {});\n}\n\nfunction mapToJsonSchema(item: any): any {\n if (isArray(item)) {\n return (item as any[]).map(mapToJsonSchema);\n }\n\n if (item.isStore || item.isJsonSchema || item.isLazyRef) {\n return item;\n }\n\n if (classOf(item) !== Object && isClass(item)) {\n return JsonEntityStore.from(item).schema;\n }\n\n if (isObject(item)) {\n return JsonSchema.from(item as any);\n }\n\n return item;\n}\n\nexport class JsonSchema extends Map<string, any> implements NestedGenerics {\n readonly isJsonSchema = true;\n readonly $hooks = new Hooks();\n readonly $required: Set<string> = new Set();\n readonly $allow: any[] = [];\n public $selfRequired: boolean;\n public $forwardGroups: boolean = false;\n protected _nullable: boolean = false;\n protected _genericLabels: string[];\n protected _nestedGenerics: Type<any>[][] = [];\n protected _alias: AliasMap = new Map();\n protected _itemSchema: JsonSchema;\n protected _target: Type<any>;\n protected _isGeneric: boolean = false;\n protected _isCollection: boolean = false;\n protected _ref: boolean = false;\n\n // protected _specs: Map<SpecTypes, any> = new Map();\n\n constructor(obj: JsonSchema | Partial<JsonSchemaObject> = {}) {\n super();\n\n if (obj) {\n this.assign(obj);\n }\n }\n\n get alias() {\n return this._alias;\n }\n\n get nestedGenerics(): any[] {\n return this._nestedGenerics;\n }\n\n set nestedGenerics(value: any[]) {\n this._nestedGenerics = value;\n }\n\n get genericLabels(): string[] {\n return this._genericLabels;\n }\n\n set genericLabels(value: string[]) {\n this._genericLabels = value;\n }\n\n get nullable(): boolean {\n return this._nullable || this.$allow.includes(null);\n }\n\n set nullable(value: boolean) {\n this._nullable = value;\n }\n\n get isClass() {\n return isClass(this.class) && ![Map, Array, Set, Object, Date, Boolean, Number, String].includes(this._target as any);\n }\n\n /**\n * Current schema is a collection\n */\n get isCollection() {\n return this._isCollection;\n }\n\n /**\n * Current schema is a generic\n */\n get isGeneric() {\n return this._isGeneric;\n }\n\n /**\n * Current schema has generics items\n */\n get hasGenerics(): boolean {\n return !!(this.nestedGenerics && this.nestedGenerics.length);\n }\n\n get genericType(): string {\n return this.get(\"$ref\");\n }\n\n get class() {\n return this.getComputedType();\n }\n\n get canRef(): boolean {\n return this._ref;\n }\n\n static from(obj: Partial<JsonSchemaObject> = {}) {\n return new JsonSchema(obj);\n }\n\n itemSchema(obj: AnyJsonSchema = {}) {\n this._itemSchema = this._itemSchema || mapToJsonSchema(obj);\n this._itemSchema.assign(obj);\n\n return this._itemSchema;\n }\n\n getAliasOf(property: AliasType) {\n return this._alias.get(property as any);\n }\n\n addAlias(property: AliasType, alias: AliasType) {\n this._alias.set(property, alias);\n this._alias.set(alias, property);\n\n return this;\n }\n\n removeAlias(property: AliasType) {\n const alias = this._alias.get(property);\n alias && this._alias.delete(alias);\n this._alias.delete(property);\n\n return this;\n }\n\n $id($id: string) {\n super.set(\"$id\", $id);\n\n return this;\n }\n\n $ref($ref: string) {\n super.set(\"$ref\", $ref);\n\n return this;\n }\n\n $schema($schema: JSONSchema6Version) {\n super.set(\"$schema\", $schema);\n\n return this;\n }\n\n /**\n * Create a ref and use name to sharing schema\n * @param name\n */\n label(name: string) {\n this._ref = true;\n\n super.set(\"name\", name);\n\n return this;\n }\n\n name(name: string) {\n super.set(\"name\", name);\n\n return this;\n }\n\n ignore(cb: boolean | IgnoreCallback) {\n if (typeof cb === \"boolean\") {\n const bool = cb;\n cb = () => bool;\n }\n\n this.$hooks.on(\"ignore\", cb);\n\n return this;\n }\n\n /**\n * This keyword can be used to supply a default JSON value associated with a particular schema.\n * It is RECOMMENDED that a default value be valid against the associated schema.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-7.3\n */\n default(value: JSONSchema6Type) {\n super.set(\"default\", value);\n\n return this;\n }\n\n /**\n * More readible form of a one-element \"enum\"\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.24\n */\n const(value: JSONSchema6Type) {\n super.set(\"const\", value);\n\n return this;\n }\n\n /**\n * This attribute is a string that provides a full description of the of purpose the instance property.\n *\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-7.2\n */\n description(description: string) {\n super.set(\"description\", description);\n\n return this;\n }\n\n /**\n * This keyword determines how child instances validate for arrays, and does not directly validate the immediate instance itself.\n * If \"items\" is an array of schemas, validation succeeds if every instance element\n * at a position greater than the size of \"items\" validates against \"additionalItems\".\n * Otherwise, \"additionalItems\" MUST be ignored, as the \"items\" schema\n * (possibly the default value of an empty schema) is applied to all elements.\n * Omitting this keyword has the same behavior as an empty schema.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.10\n */\n additionalItems(additionalItems: boolean | AnyJsonSchema) {\n super.set(\"additionalItems\", mapToJsonSchema(additionalItems));\n\n return this;\n }\n\n /**\n * An array instance is valid against \"contains\" if at least one of its elements is valid against the given schema.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.14\n */\n contains(contains: JSONSchema6Definition) {\n super.set(\"contains\", mapToJsonSchema(contains));\n\n return this;\n }\n\n /**\n * Array of examples with no validation effect the value of \"default\" is usable as an example without repeating it under this keyword\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-7.4\n */\n examples(examples: JSONSchema6Type[]) {\n super.set(\"examples\", examples);\n\n return this;\n }\n\n /**\n * Array of examples with no validation effect the value of \"default\" is usable as an example without repeating it under this keyword\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-7.4\n */\n example(...examples: JSONSchema6Type[]) {\n return this.examples(examples);\n }\n\n /**\n * This keyword determines how child instances validate for arrays, and does not directly validate the immediate instance itself.\n * Omitting this keyword has the same behavior as an empty schema.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.9\n */\n items(items: AnyJsonSchema | AnyJsonSchema[]) {\n super.set(\"items\", (this._itemSchema = mapToJsonSchema(items)));\n\n return this;\n }\n\n /**\n * Must be a non-negative integer.\n * An array instance is valid against \"maxItems\" if its size is less than, or equal to, the value of this keyword.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.11\n */\n maxItems(maxItems: number) {\n super.set(\"maxItems\", maxItems);\n\n return this;\n }\n\n /**\n * Must be a non-negative integer.\n * An array instance is valid against \"maxItems\" if its size is greater than, or equal to, the value of this keyword.\n * Omitting this keyword has the same behavior as a value of 0.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.12\n */\n minItems(minItems: number) {\n super.set(\"minItems\", minItems);\n\n return this;\n }\n\n /**\n * If this keyword has boolean value false, the instance validates successfully.\n * If it has boolean value true, the instance validates successfully if all of its elements are unique.\n * Omitting this keyword has the same behavior as a value of false.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.13\n */\n uniqueItems(uniqueItems: boolean) {\n super.set(\"uniqueItems\", uniqueItems);\n\n return this;\n }\n\n /**\n * Must be a non-negative integer.\n * An object instance is valid against \"maxProperties\" if its number of properties is less than, or equal to, the value of this keyword.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.15\n */\n maxProperties(maxProperties: number) {\n super.set(\"maxProperties\", maxProperties);\n\n return this;\n }\n\n /**\n * Must be a non-negative integer.\n * An object instance is valid against \"maxProperties\" if its number of properties is greater than,\n * or equal to, the value of this keyword.\n * Omitting this keyword has the same behavior as a value of 0.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.16\n */\n minProperties(minProperties: number) {\n super.set(\"minProperties\", minProperties);\n\n return this;\n }\n\n allow(...allow: any[]) {\n this.$allow.push(...allow);\n return this;\n }\n\n /**\n * Elements of this array must be unique.\n * An object instance is valid against this keyword if every item in the array is the name of a property in the instance.\n * Omitting this keyword has the same behavior as an empty array.\n *\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.17\n */\n required(required: boolean | string[] = true) {\n if (isArray(required)) {\n this.$required.clear();\n\n required.forEach((value: any) => this.$required.add(value));\n } else {\n const schema = this.clone();\n schema.$selfRequired = required;\n return schema;\n }\n\n return this;\n }\n\n addRequired(property: string) {\n this.$required.add(property);\n\n return this;\n }\n\n removeRequired(property: string) {\n this.$required.delete(property);\n\n return this;\n }\n\n isRequired(property: string): boolean {\n return this.$required.has(property);\n }\n\n /**\n * This keyword determines how child instances validate for objects, and does not directly validate the immediate instance itself.\n * Validation succeeds if, for each name that appears in both the instance and as a name within this keyword's value,\n * the child instance for that name successfully validates against the corresponding schema.\n * Omitting this keyword has the same behavior as an empty object.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.18\n */\n properties(properties: AnyJsonSchema | Record<string, AnyJsonSchema>) {\n super.set(\"properties\", mapProperties(properties));\n\n return this;\n }\n\n addProperty(key: string, schema: AnyJsonSchema) {\n const properties = this.get(\"properties\") || {};\n\n properties[key] = schema;\n\n super.set(\"properties\", mapProperties(properties));\n\n return this;\n }\n\n /**\n * This attribute is an object that defines the schema for a set of property names of an object instance.\n * The name of each property of this attribute's object is a regular expression pattern in the ECMA 262, while the value is a schema.\n * If the pattern matches the name of a property on the instance object, the value of the instance's property\n * MUST be valid against the pattern name's schema value.\n * Omitting this keyword has the same behavior as an empty object.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.19\n */\n patternProperties(patternProperties: Record<string, AnyJsonSchema>) {\n super.set(\"patternProperties\", mapProperties(patternProperties));\n\n return this;\n }\n\n /**\n * This attribute defines a schema for all properties that are not explicitly defined in an object type definition.\n * If specified, the value MUST be a schema or a boolean.\n * If false is provided, no additional properties are allowed beyond the properties defined in the schema.\n * The default value is an empty schema which allows any value for additional properties.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.20\n */\n additionalProperties(additionalProperties: boolean | AnyJsonSchema) {\n super.set(\"additionalProperties\", mapToJsonSchema(additionalProperties));\n\n return this;\n }\n\n /**\n * This attribute defines a schema for all properties that are not explicitly defined in an object type definition.\n * If specified, the value MUST be a schema or a boolean.\n * If false is provided, no additional properties are allowed beyond the properties defined in the schema.\n * The default value is an empty schema which allows any value for additional properties.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.20\n * @alias additionalProperties\n * @param unknown\n */\n unknown(unknown: boolean = true) {\n return this.additionalProperties(unknown);\n }\n\n /**\n * This keyword specifies rules that are evaluated if the instance is an object and contains a certain property.\n * Each property specifies a dependency.\n * If the dependency value is an array, each element in the array must be unique.\n * Omitting this keyword has the same behavior as an empty object.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.21\n */\n dependencies(dependencies: {[p: string]: JSONSchema6Definition | JsonSchema | string[]}) {\n super.set(\"dependencies\", mapProperties(dependencies));\n\n return this;\n }\n\n /**\n * Takes a schema which validates the names of all properties rather than their values.\n * Note the property name that the schema is testing will always be a string.\n * Omitting this keyword has the same behavior as an empty schema.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.22\n */\n propertyNames(propertyNames: JSONSchema6Definition | JsonSchema) {\n super.set(\"propertyNames\", mapToJsonSchema(propertyNames));\n\n return this;\n }\n\n /**\n * This provides an enumeration of all possible values that are valid\n * for the instance property. This MUST be an array, and each item in\n * the array represents a possible value for the instance value. If\n * this attribute is defined, the instance value MUST be one of the\n * values in the array in order for the schema to be valid.\n *\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.23\n */\n enum(enumValues: JSONSchema6Type[]): this {\n super.set(\"enum\", uniq(enumValues));\n\n return this;\n }\n\n /**\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-7.1\n */\n definitions(definitions: Record<string, AnyJsonSchema>) {\n super.set(\"definitions\", mapProperties(definitions));\n\n return this;\n }\n\n /**\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.26\n */\n allOf(allOf: AnyJsonSchema[]) {\n super.set(\"allOf\", allOf.map(mapToJsonSchema));\n\n return this;\n }\n\n /**\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.27\n */\n anyOf(anyOf: AnyJsonSchema[]) {\n super.set(\"anyOf\", anyOf.map(mapToJsonSchema));\n\n return this;\n }\n\n /**\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.28\n */\n oneOf(oneOf: AnyJsonSchema[]) {\n super.set(\"oneOf\", oneOf.map(mapToJsonSchema));\n\n return this;\n }\n\n /**\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.29\n */\n not(not: AnyJsonSchema) {\n super.set(\"not\", mapToJsonSchema(not));\n\n return this;\n }\n\n /**\n * Must be strictly greater than 0.\n * A numeric instance is valid only if division by this keyword's value results in an integer.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.1\n */\n multipleOf(multipleOf: number): this {\n super.set(\"multipleOf\", multipleOf);\n\n return this;\n }\n\n /**\n * Representing an inclusive upper limit for a numeric instance.\n * This keyword validates only if the instance is less than or exactly equal to \"maximum\".\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.2\n */\n maximum(maximum: number): this {\n super.set(\"maximum\", maximum);\n\n return this;\n }\n\n /**\n * Representing an exclusive upper limit for a numeric instance.\n * This keyword validates only if the instance is strictly less than (not equal to) to \"exclusiveMaximum\".\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.3\n */\n exclusiveMaximum(exclusiveMaximum: number): this {\n super.set(\"exclusiveMaximum\", exclusiveMaximum);\n\n return this;\n }\n\n /**\n * Representing an inclusive lower limit for a numeric instance.\n * This keyword validates only if the instance is greater than or exactly equal to \"minimum\".\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.4\n */\n minimum(minimum: number): this {\n super.set(\"minimum\", minimum);\n\n return this;\n }\n\n /**\n * Representing an exclusive lower limit for a numeric instance.\n * This keyword validates only if the instance is strictly greater than (not equal to) to \"exclusiveMinimum\".\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.5\n */\n exclusiveMinimum(exclusiveMinimum: number): this {\n super.set(\"exclusiveMinimum\", exclusiveMinimum);\n\n return this;\n }\n\n /**\n * Must be a non-negative integer.\n * A string instance is valid against this keyword if its length is less than, or equal to, the value of this keyword.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.6\n */\n maxLength(maxLength: number): this {\n super.set(\"maxLength\", maxLength);\n\n return this;\n }\n\n /**\n * Must be a non-negative integer.\n * A string instance is valid against this keyword if its length is greater than, or equal to, the value of this keyword.\n * Omitting this keyword has the same behavior as a value of 0.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.7\n */\n minLength(minLength: number): this {\n super.set(\"minLength\", minLength);\n\n return this;\n }\n\n /**\n * Should be a valid regular expression, according to the ECMA 262 regular expression dialect.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.8\n */\n pattern(pattern: string | RegExp): this {\n super.set(\"pattern\", toJsonRegex(pattern));\n\n return this;\n }\n\n /**\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-8\n */\n format(format: JsonFormatTypes | ValueOf<JsonFormatTypes>): this {\n super.set(\"format\", format);\n\n return this;\n }\n\n /**\n * A single type, or a union of simple types\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.25\n */\n type(type: any | JSONSchema6TypeName | JSONSchema6TypeName[]): this {\n switch (type) {\n case Map:\n super.set(\"type\", getJsonType(type));\n this._target = type;\n this._isCollection = true;\n if (!this.has(\"additionalProperties\")) {\n super.set(\"additionalProperties\", this.itemSchema({}));\n }\n break;\n\n case Array:\n super.set(\"type\", getJsonType(type));\n this._target = type;\n this._isCollection = true;\n\n if (!this.has(\"items\")) {\n super.set(\"items\", this.itemSchema({}));\n }\n break;\n\n case Set:\n super.set(\"type\", getJsonType(type));\n this._target = type;\n this._isCollection = true;\n this.uniqueItems(true);\n\n if (!this.has(\"items\")) {\n super.set(\"items\", this.itemSchema({}));\n }\n break;\n\n case \"integer\":\n super.set(\"type\", getJsonType(type));\n this.integer();\n break;\n\n case Object:\n case Date:\n case Boolean:\n case Number:\n case String:\n super.set(\"type\", getJsonType(type));\n this._target = type;\n if (!this.has(\"properties\")) {\n super.set(\"properties\", {});\n }\n break;\n\n default:\n if (isClass(type) || isFunction(type)) {\n super.set(\"type\", undefined);\n this._target = type;\n\n if (!this.has(\"properties\")) {\n super.set(\"properties\", {});\n }\n } else {\n const jsonType = getJsonType(type);\n if (jsonType === \"generic\") {\n this._isGeneric = true;\n super.set(\"$ref\", type);\n } else {\n super.set(\"type\", jsonType);\n }\n }\n }\n\n return this;\n }\n\n any(...types: any[]) {\n const hasClasses = types.filter((type) => isClass(type));\n\n if (hasClasses.length >= 2) {\n this.anyOf(\n types.filter((value) => {\n if (value !== null) {\n this.nullable = true;\n return true;\n }\n return false;\n })\n );\n } else {\n // TODO when OS3 will the only minimal supported version, we'll can remove this code\n types = uniq(types.length ? types : [\"integer\", \"number\", \"string\", \"boolean\", \"array\", \"object\", \"null\"]).map(getJsonType);\n\n if (types.includes(\"null\")) {\n this.nullable = true;\n }\n\n this.type(types.length === 1 ? types[0] : types);\n }\n\n return this;\n }\n\n integer() {\n super.set(\"type\", \"integer\");\n super.set(\"multipleOf\", 1.0);\n\n return this;\n }\n\n /**\n * This attribute is a string that provides a short description of the instance property.\n *\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-7.2\n */\n title(title: string): this {\n super.set(\"title\", title);\n\n return this;\n }\n\n readOnly(readOnly: boolean): this {\n super.set(\"readOnly\", readOnly);\n\n return this;\n }\n\n writeOnly(readOnly: boolean): this {\n super.set(\"writeOnly\", readOnly);\n\n return this;\n }\n\n customKey(key: string, value: any) {\n super.set(`#${key}`, value);\n\n return this;\n }\n\n toObject(options?: JsonSchemaOptions) {\n return this.toJSON(options);\n }\n\n toJSON(options?: JsonSchemaOptions) {\n let addDef = false;\n\n if (!options) {\n addDef = true;\n options = {schemas: {}};\n }\n\n const schema = execMapper(\"schema\", this, options);\n\n if (addDef && options.schemas && Object.keys(options.schemas).length) {\n schema.definitions = options.schemas;\n }\n\n return schema;\n }\n\n assign(obj: JsonSchema | Partial<JsonSchemaObject> = {}) {\n const entries = obj instanceof JsonSchema ? [...obj.entries()] : Object.entries(obj);\n\n entries.forEach(([key, value]) => {\n this.set(key, value);\n });\n\n if (obj instanceof JsonSchema) {\n this.$selfRequired = obj.$selfRequired;\n\n obj.$required.forEach((key) => {\n this.$required.add(key);\n });\n\n this._ref = obj._ref;\n this._alias = new Map(this._alias.entries());\n obj._genericLabels && (this._genericLabels = [...obj._genericLabels]);\n this._nestedGenerics = obj._nestedGenerics.map((item) => [...item]);\n this._target = obj._target;\n this._isGeneric = obj._isGeneric;\n this._isCollection = obj._isCollection;\n this._ref = obj._ref;\n\n super.set(\"type\", obj.get(\"type\"));\n }\n\n return this;\n }\n\n set(key: string, value: any): this {\n if (key in this) {\n isFunction((this as any)[key]) && (this as any)[key](value);\n } else {\n super.set(key, value);\n }\n\n return this;\n }\n\n /**\n * Return the itemSchema computed type.\n * If the type is a function used for recursive model,\n * the function will be called to get the right type.\n */\n getComputedType(): any {\n return getComputedType(this._target);\n }\n\n getComputedItemType(): any {\n return this._itemSchema ? this._itemSchema.getComputedType() : this.getComputedType();\n }\n\n /**\n * Return the Json type as string\n */\n getJsonType(): string | string[] {\n return this.get(\"type\") || getJsonType(this.getComputedType());\n }\n\n getTarget() {\n return this._target;\n }\n\n /**\n * Get the symbolic name of the entity\n */\n getName() {\n return this.get(\"name\") || (this._target ? nameOf(classOf(this.getComputedType())) : \"\");\n }\n\n clone() {\n return new JsonSchema(this);\n }\n}\n"]}
1
+ {"version":3,"file":"JsonSchema.js","sourceRoot":"","sources":["../../../src/domain/JsonSchema.ts"],"names":[],"mappings":";;;;;AAAA,qCAA+G;AAI/G,uFAAmE;AAEnE,8DAAyD;AACzD,sDAAiD;AACjD,sDAAiD;AAIjD,uDAAkD;AAWlD,SAAS,aAAa,CAAC,UAA+B;IACpD,uBAAuB;IACvB,IAAI,UAAU,YAAY,UAAU,EAAE;QACpC,OAAO,UAAU,CAAC;KACnB;IAED,OAAO,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,MAAM,CAAM,CAAC,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,EAAE;QAC1E,UAAU,CAAC,IAAA,yBAAW,EAAC,GAAG,CAAC,CAAC,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;QAEvD,OAAO,UAAU,CAAC;IACpB,CAAC,EAAE,EAAE,CAAC,C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AC;IACd,CAAC;IAED;;;;OAIG;IACH,eAAe;QACb,OAAO,IAAA,iCAAe,EAAC,oCAAA,IAAI,0BAAQ,CAAC,CAAC;IACvC,CAAC;IAED,mBAAmB;QACjB,OAAO,oCAAA,IAAI,8BAAY,CAAC,CAAC,CAAC,oCAAA,IAAI,8BAAY,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC;IACxF,CAAC;IAED;;OAEG;IACH,WAAW;QACT,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,IAAA,yBAAW,EAAC,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC;IACjE,CAAC;IAED,SAAS;QACP,OAAO,oCAAA,IAAI,0BAAQ,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,OAAO;QACL,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,oCAAA,IAAI,0BAAQ,CAAC,CAAC,CAAC,IAAA,aAAM,EAAC,IAAA,cAAO,EAAC,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAC3F,CAAC;IAED,KAAK;QACH,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;CACF;AA70BD,gCA60BC","sourcesContent":["import {classOf, Hooks, isArray, isClass, isFunction, isObject, nameOf, Type, uniq, ValueOf} from \"@tsed/core\";\nimport type {JSONSchema6, JSONSchema6Definition, JSONSchema6Type, JSONSchema6TypeName, JSONSchema6Version} from \"json-schema\";\nimport {JsonSchemaOptions} from \"../interfaces\";\nimport {IgnoreCallback} from \"../interfaces/IgnoreCallback\";\nimport {execMapper} from \"../registries/JsonSchemaMapperContainer\";\nimport {NestedGenerics} from \"../utils/generics\";\nimport {getComputedType} from \"../utils/getComputedType\";\nimport {getJsonType} from \"../utils/getJsonType\";\nimport {toJsonRegex} from \"../utils/toJsonRegex\";\nimport {AliasMap, AliasType} from \"./JsonAliasMap\";\nimport {JsonFormatTypes} from \"./JsonFormatTypes\";\nimport {JsonLazyRef} from \"./JsonLazyRef\";\nimport {JsonEntityStore} from \"./JsonEntityStore\";\n\nexport interface JsonSchemaObject extends JSONSchema6, Record<string, any> {\n type: (any | JSONSchema6TypeName) | (any | JSONSchema6TypeName)[];\n additionalProperties?: boolean | JSONSchema6 | any;\n propertyNames?: boolean | JSONSchema6 | any;\n items?: (any | JSONSchema6Definition) | (any | JSONSchema6Definition)[];\n}\n\nexport type AnyJsonSchema = Partial<JsonSchemaObject> | JsonSchema | JsonLazyRef | any;\n\nfunction mapProperties(properties: Record<string, any>) {\n // istanbul ignore next\n if (properties instanceof JsonSchema) {\n return properties;\n }\n\n return Object.entries(properties).reduce<any>((properties, [key, schema]) => {\n properties[toJsonRegex(key)] = mapToJsonSchema(schema);\n\n return properties;\n }, {});\n}\n\nfunction mapToJsonSchema(item: any): any {\n if (isArray(item)) {\n return (item as any[]).map(mapToJsonSchema);\n }\n\n if (item.isStore || item.isJsonSchema || item.isLazyRef) {\n return item;\n }\n\n if (classOf(item) !== Object && isClass(item)) {\n return JsonEntityStore.from(item).schema;\n }\n\n if (isObject(item)) {\n return JsonSchema.from(item as any);\n }\n\n return item;\n}\n\nexport class JsonSchema extends Map<string, any> implements NestedGenerics {\n readonly isJsonSchema = true;\n readonly $hooks = new Hooks();\n readonly $required: Set<string> = new Set();\n readonly $allow: any[] = [];\n public $selfRequired: boolean;\n public $forwardGroups: boolean = false;\n\n #nullable: boolean = false;\n #genericLabels: string[];\n #nestedGenerics: Type<any>[][] = [];\n #alias: AliasMap = new Map();\n #itemSchema: JsonSchema;\n #target: Type<any>;\n #isGeneric: boolean = false;\n #isCollection: boolean = false;\n #ref: boolean = false;\n\n constructor(obj: JsonSchema | Partial<JsonSchemaObject> = {}) {\n super();\n\n if (obj) {\n this.assign(obj);\n }\n }\n\n get alias() {\n return this.#alias;\n }\n\n get nestedGenerics(): any[] {\n return this.#nestedGenerics;\n }\n\n set nestedGenerics(value: any[]) {\n this.#nestedGenerics = value;\n }\n\n get genericLabels(): string[] {\n return this.#genericLabels;\n }\n\n set genericLabels(value: string[]) {\n this.#genericLabels = value;\n }\n\n get isClass() {\n return isClass(this.class) && ![Map, Array, Set, Object, Date, Boolean, Number, String].includes(this.#target as any);\n }\n\n /**\n * Current schema is a collection\n */\n get isCollection() {\n return this.#isCollection;\n }\n\n /**\n * Current schema is a generic\n */\n get isGeneric() {\n return this.#isGeneric;\n }\n\n /**\n * Current schema has generics items\n */\n get hasGenerics(): boolean {\n return !!(this.nestedGenerics && this.nestedGenerics.length);\n }\n\n get genericType(): string {\n return this.get(\"$ref\");\n }\n\n get class() {\n return this.getComputedType();\n }\n\n get canRef(): boolean {\n return this.#ref;\n }\n\n get isNullable(): boolean {\n return this.#nullable || this.$allow.includes(null);\n }\n\n get isReadOnly() {\n return this.get(\"readOnly\");\n }\n\n get isWriteOnly() {\n return this.get(\"writeOnly\");\n }\n\n static from(obj: Partial<JsonSchemaObject> = {}) {\n return new JsonSchema(obj);\n }\n\n nullable(value: boolean) {\n this.#nullable = value;\n }\n\n itemSchema(obj: AnyJsonSchema = {}) {\n this.#itemSchema = this.#itemSchema || mapToJsonSchema(obj);\n this.#itemSchema.assign(obj);\n\n return this.#itemSchema;\n }\n\n getAliasOf(property: AliasType) {\n return this.#alias.get(property as any);\n }\n\n addAlias(property: AliasType, alias: AliasType) {\n this.#alias.set(property, alias);\n this.#alias.set(alias, property);\n\n return this;\n }\n\n removeAlias(property: AliasType) {\n const alias = this.#alias.get(property);\n alias && this.#alias.delete(alias);\n this.#alias.delete(property);\n\n return this;\n }\n\n $id($id: string) {\n super.set(\"$id\", $id);\n\n return this;\n }\n\n $ref($ref: string) {\n super.set(\"$ref\", $ref);\n\n return this;\n }\n\n $schema($schema: JSONSchema6Version) {\n super.set(\"$schema\", $schema);\n\n return this;\n }\n\n /**\n * Create a ref and use name to sharing schema\n * @param name\n */\n label(name: string) {\n this.#ref = true;\n\n super.set(\"name\", name);\n\n return this;\n }\n\n name(name: string) {\n super.set(\"name\", name);\n\n return this;\n }\n\n ignore(cb: boolean | IgnoreCallback) {\n if (typeof cb === \"boolean\") {\n const bool = cb;\n cb = () => bool;\n }\n\n this.$hooks.on(\"ignore\", cb);\n\n return this;\n }\n\n /**\n * This keyword can be used to supply a default JSON value associated with a particular schema.\n * It is RECOMMENDED that a default value be valid against the associated schema.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-7.3\n */\n default(value: JSONSchema6Type) {\n super.set(\"default\", value);\n\n return this;\n }\n\n /**\n * More readible form of a one-element \"enum\"\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.24\n */\n const(value: JSONSchema6Type) {\n super.set(\"const\", value);\n\n return this;\n }\n\n /**\n * This attribute is a string that provides a full description of the of purpose the instance property.\n *\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-7.2\n */\n description(description: string) {\n super.set(\"description\", description);\n\n return this;\n }\n\n /**\n * This keyword determines how child instances validate for arrays, and does not directly validate the immediate instance itself.\n * If \"items\" is an array of schemas, validation succeeds if every instance element\n * at a position greater than the size of \"items\" validates against \"additionalItems\".\n * Otherwise, \"additionalItems\" MUST be ignored, as the \"items\" schema\n * (possibly the default value of an empty schema) is applied to all elements.\n * Omitting this keyword has the same behavior as an empty schema.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.10\n */\n additionalItems(additionalItems: boolean | AnyJsonSchema) {\n super.set(\"additionalItems\", mapToJsonSchema(additionalItems));\n\n return this;\n }\n\n /**\n * An array instance is valid against \"contains\" if at least one of its elements is valid against the given schema.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.14\n */\n contains(contains: JSONSchema6Definition) {\n super.set(\"contains\", mapToJsonSchema(contains));\n\n return this;\n }\n\n /**\n * Array of examples with no validation effect the value of \"default\" is usable as an example without repeating it under this keyword\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-7.4\n */\n examples(examples: JSONSchema6Type[]) {\n super.set(\"examples\", examples);\n\n return this;\n }\n\n /**\n * Array of examples with no validation effect the value of \"default\" is usable as an example without repeating it under this keyword\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-7.4\n */\n example(...examples: JSONSchema6Type[]) {\n return this.examples(examples);\n }\n\n /**\n * This keyword determines how child instances validate for arrays, and does not directly validate the immediate instance itself.\n * Omitting this keyword has the same behavior as an empty schema.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.9\n */\n items(items: AnyJsonSchema | AnyJsonSchema[]) {\n super.set(\"items\", (this.#itemSchema = mapToJsonSchema(items)));\n\n return this;\n }\n\n /**\n * Must be a non-negative integer.\n * An array instance is valid against \"maxItems\" if its size is less than, or equal to, the value of this keyword.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.11\n */\n maxItems(maxItems: number) {\n super.set(\"maxItems\", maxItems);\n\n return this;\n }\n\n /**\n * Must be a non-negative integer.\n * An array instance is valid against \"maxItems\" if its size is greater than, or equal to, the value of this keyword.\n * Omitting this keyword has the same behavior as a value of 0.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.12\n */\n minItems(minItems: number) {\n super.set(\"minItems\", minItems);\n\n return this;\n }\n\n /**\n * If this keyword has boolean value false, the instance validates successfully.\n * If it has boolean value true, the instance validates successfully if all of its elements are unique.\n * Omitting this keyword has the same behavior as a value of false.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.13\n */\n uniqueItems(uniqueItems: boolean) {\n super.set(\"uniqueItems\", uniqueItems);\n\n return this;\n }\n\n /**\n * Must be a non-negative integer.\n * An object instance is valid against \"maxProperties\" if its number of properties is less than, or equal to, the value of this keyword.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.15\n */\n maxProperties(maxProperties: number) {\n super.set(\"maxProperties\", maxProperties);\n\n return this;\n }\n\n /**\n * Must be a non-negative integer.\n * An object instance is valid against \"maxProperties\" if its number of properties is greater than,\n * or equal to, the value of this keyword.\n * Omitting this keyword has the same behavior as a value of 0.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.16\n */\n minProperties(minProperties: number) {\n super.set(\"minProperties\", minProperties);\n\n return this;\n }\n\n allow(...allow: any[]) {\n this.$allow.push(...allow);\n return this;\n }\n\n /**\n * Elements of this array must be unique.\n * An object instance is valid against this keyword if every item in the array is the name of a property in the instance.\n * Omitting this keyword has the same behavior as an empty array.\n *\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.17\n */\n required(required: boolean | string[] = true) {\n if (isArray(required)) {\n this.$required.clear();\n\n required.forEach((value: any) => this.$required.add(value));\n } else {\n const schema = this.clone();\n schema.$selfRequired = required;\n return schema;\n }\n\n return this;\n }\n\n addRequired(property: string) {\n this.$required.add(property);\n\n return this;\n }\n\n removeRequired(property: string) {\n this.$required.delete(property);\n\n return this;\n }\n\n isRequired(property: string): boolean {\n return this.$required.has(property);\n }\n\n /**\n * This keyword determines how child instances validate for objects, and does not directly validate the immediate instance itself.\n * Validation succeeds if, for each name that appears in both the instance and as a name within this keyword's value,\n * the child instance for that name successfully validates against the corresponding schema.\n * Omitting this keyword has the same behavior as an empty object.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.18\n */\n properties(properties: AnyJsonSchema | Record<string, AnyJsonSchema>) {\n super.set(\"properties\", mapProperties(properties));\n\n return this;\n }\n\n addProperty(key: string, schema: AnyJsonSchema) {\n const properties = this.get(\"properties\") || {};\n\n properties[key] = schema;\n\n super.set(\"properties\", mapProperties(properties));\n\n return this;\n }\n\n /**\n * This attribute is an object that defines the schema for a set of property names of an object instance.\n * The name of each property of this attribute's object is a regular expression pattern in the ECMA 262, while the value is a schema.\n * If the pattern matches the name of a property on the instance object, the value of the instance's property\n * MUST be valid against the pattern name's schema value.\n * Omitting this keyword has the same behavior as an empty object.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.19\n */\n patternProperties(patternProperties: Record<string, AnyJsonSchema>) {\n super.set(\"patternProperties\", mapProperties(patternProperties));\n\n return this;\n }\n\n /**\n * This attribute defines a schema for all properties that are not explicitly defined in an object type definition.\n * If specified, the value MUST be a schema or a boolean.\n * If false is provided, no additional properties are allowed beyond the properties defined in the schema.\n * The default value is an empty schema which allows any value for additional properties.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.20\n */\n additionalProperties(additionalProperties: boolean | AnyJsonSchema) {\n super.set(\"additionalProperties\", mapToJsonSchema(additionalProperties));\n\n return this;\n }\n\n /**\n * This attribute defines a schema for all properties that are not explicitly defined in an object type definition.\n * If specified, the value MUST be a schema or a boolean.\n * If false is provided, no additional properties are allowed beyond the properties defined in the schema.\n * The default value is an empty schema which allows any value for additional properties.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.20\n * @alias additionalProperties\n * @param unknown\n */\n unknown(unknown: boolean = true) {\n return this.additionalProperties(unknown);\n }\n\n /**\n * This keyword specifies rules that are evaluated if the instance is an object and contains a certain property.\n * Each property specifies a dependency.\n * If the dependency value is an array, each element in the array must be unique.\n * Omitting this keyword has the same behavior as an empty object.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.21\n */\n dependencies(dependencies: {[p: string]: JSONSchema6Definition | JsonSchema | string[]}) {\n super.set(\"dependencies\", mapProperties(dependencies));\n\n return this;\n }\n\n /**\n * Takes a schema which validates the names of all properties rather than their values.\n * Note the property name that the schema is testing will always be a string.\n * Omitting this keyword has the same behavior as an empty schema.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.22\n */\n propertyNames(propertyNames: JSONSchema6Definition | JsonSchema) {\n super.set(\"propertyNames\", mapToJsonSchema(propertyNames));\n\n return this;\n }\n\n /**\n * This provides an enumeration of all possible values that are valid\n * for the instance property. This MUST be an array, and each item in\n * the array represents a possible value for the instance value. If\n * this attribute is defined, the instance value MUST be one of the\n * values in the array in order for the schema to be valid.\n *\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.23\n */\n enum(enumValues: JSONSchema6Type[]): this {\n super.set(\"enum\", uniq(enumValues));\n\n return this;\n }\n\n /**\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-7.1\n */\n definitions(definitions: Record<string, AnyJsonSchema>) {\n super.set(\"definitions\", mapProperties(definitions));\n\n return this;\n }\n\n /**\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.26\n */\n allOf(allOf: AnyJsonSchema[]) {\n super.set(\"allOf\", allOf.map(mapToJsonSchema));\n\n return this;\n }\n\n /**\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.27\n */\n anyOf(anyOf: AnyJsonSchema[]) {\n super.set(\"anyOf\", anyOf.map(mapToJsonSchema));\n\n return this;\n }\n\n /**\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.28\n */\n oneOf(oneOf: AnyJsonSchema[]) {\n super.set(\"oneOf\", oneOf.map(mapToJsonSchema));\n\n return this;\n }\n\n /**\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.29\n */\n not(not: AnyJsonSchema) {\n super.set(\"not\", mapToJsonSchema(not));\n\n return this;\n }\n\n /**\n * Must be strictly greater than 0.\n * A numeric instance is valid only if division by this keyword's value results in an integer.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.1\n */\n multipleOf(multipleOf: number): this {\n super.set(\"multipleOf\", multipleOf);\n\n return this;\n }\n\n /**\n * Representing an inclusive upper limit for a numeric instance.\n * This keyword validates only if the instance is less than or exactly equal to \"maximum\".\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.2\n */\n maximum(maximum: number): this {\n super.set(\"maximum\", maximum);\n\n return this;\n }\n\n /**\n * Representing an exclusive upper limit for a numeric instance.\n * This keyword validates only if the instance is strictly less than (not equal to) to \"exclusiveMaximum\".\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.3\n */\n exclusiveMaximum(exclusiveMaximum: number): this {\n super.set(\"exclusiveMaximum\", exclusiveMaximum);\n\n return this;\n }\n\n /**\n * Representing an inclusive lower limit for a numeric instance.\n * This keyword validates only if the instance is greater than or exactly equal to \"minimum\".\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.4\n */\n minimum(minimum: number): this {\n super.set(\"minimum\", minimum);\n\n return this;\n }\n\n /**\n * Representing an exclusive lower limit for a numeric instance.\n * This keyword validates only if the instance is strictly greater than (not equal to) to \"exclusiveMinimum\".\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.5\n */\n exclusiveMinimum(exclusiveMinimum: number): this {\n super.set(\"exclusiveMinimum\", exclusiveMinimum);\n\n return this;\n }\n\n /**\n * Must be a non-negative integer.\n * A string instance is valid against this keyword if its length is less than, or equal to, the value of this keyword.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.6\n */\n maxLength(maxLength: number): this {\n super.set(\"maxLength\", maxLength);\n\n return this;\n }\n\n /**\n * Must be a non-negative integer.\n * A string instance is valid against this keyword if its length is greater than, or equal to, the value of this keyword.\n * Omitting this keyword has the same behavior as a value of 0.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.7\n */\n minLength(minLength: number): this {\n super.set(\"minLength\", minLength);\n\n return this;\n }\n\n /**\n * Should be a valid regular expression, according to the ECMA 262 regular expression dialect.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.8\n */\n pattern(pattern: string | RegExp): this {\n super.set(\"pattern\", toJsonRegex(pattern));\n\n return this;\n }\n\n /**\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-8\n */\n format(format: JsonFormatTypes | ValueOf<JsonFormatTypes>): this {\n super.set(\"format\", format);\n\n return this;\n }\n\n /**\n * A single type, or a union of simple types\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.25\n */\n type(type: any | JSONSchema6TypeName | JSONSchema6TypeName[]): this {\n switch (type) {\n case Map:\n super.set(\"type\", getJsonType(type));\n this.#target = type;\n this.#isCollection = true;\n if (!this.has(\"additionalProperties\")) {\n super.set(\"additionalProperties\", this.itemSchema({}));\n }\n break;\n\n case Array:\n super.set(\"type\", getJsonType(type));\n this.#target = type;\n this.#isCollection = true;\n\n if (!this.has(\"items\")) {\n super.set(\"items\", this.itemSchema({}));\n }\n break;\n\n case Set:\n super.set(\"type\", getJsonType(type));\n this.#target = type;\n this.#isCollection = true;\n this.uniqueItems(true);\n\n if (!this.has(\"items\")) {\n super.set(\"items\", this.itemSchema({}));\n }\n break;\n\n case \"integer\":\n super.set(\"type\", getJsonType(type));\n this.integer();\n break;\n\n case Object:\n case Date:\n case Boolean:\n case Number:\n case String:\n super.set(\"type\", getJsonType(type));\n this.#target = type;\n if (!this.has(\"properties\")) {\n super.set(\"properties\", {});\n }\n break;\n\n default:\n if (isClass(type) || isFunction(type)) {\n super.set(\"type\", undefined);\n this.#target = type;\n\n if (!this.has(\"properties\")) {\n super.set(\"properties\", {});\n }\n } else {\n const jsonType = getJsonType(type);\n if (jsonType === \"generic\") {\n this.#isGeneric = true;\n super.set(\"$ref\", type);\n } else {\n super.set(\"type\", jsonType);\n }\n }\n }\n\n return this;\n }\n\n any(...types: any[]) {\n const hasClasses = types.filter((type) => isClass(type));\n\n if (hasClasses.length >= 2) {\n this.oneOf(\n types.filter((value) => {\n if (value !== null) {\n this.nullable(true);\n return true;\n }\n return false;\n })\n );\n } else {\n // TODO when OS3 will the only minimal supported version, we'll can remove this code\n if (types.length) {\n types = uniq(types).map(getJsonType);\n\n if (types.includes(\"null\")) {\n this.nullable(true);\n types = types.filter((o) => o !== \"null\");\n }\n } else {\n types = [\"integer\", \"number\", \"string\", \"boolean\", \"array\", \"object\"];\n this.nullable(true);\n }\n\n this.type(types.length === 1 ? types[0] : types);\n }\n\n return this;\n }\n\n integer() {\n super.set(\"type\", \"integer\");\n super.set(\"multipleOf\", 1.0);\n\n return this;\n }\n\n /**\n * This attribute is a string that provides a short description of the instance property.\n *\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-7.2\n */\n title(title: string): this {\n super.set(\"title\", title);\n\n return this;\n }\n\n readOnly(readOnly: boolean): this {\n super.set(\"readOnly\", readOnly);\n\n return this;\n }\n\n writeOnly(readOnly: boolean): this {\n super.set(\"writeOnly\", readOnly);\n\n return this;\n }\n\n customKey(key: string, value: any) {\n super.set(`#${key}`, value);\n\n return this;\n }\n\n toObject(options?: JsonSchemaOptions) {\n return this.toJSON(options);\n }\n\n toJSON(options?: JsonSchemaOptions) {\n let addDef = false;\n\n if (!options) {\n addDef = true;\n options = {schemas: {}};\n }\n\n const schema = execMapper(\"schema\", this, options);\n\n if (addDef && options.schemas && Object.keys(options.schemas).length) {\n schema.definitions = options.schemas;\n }\n\n return schema;\n }\n\n assign(obj: JsonSchema | Partial<JsonSchemaObject> = {}) {\n const entries = obj instanceof JsonSchema ? [...obj.entries()] : Object.entries(obj);\n entries.forEach(([key, value]) => {\n this.set(key, value);\n });\n\n if (obj instanceof JsonSchema) {\n this.$selfRequired = obj.$selfRequired;\n\n obj.$required.forEach((key) => {\n this.$required.add(key);\n });\n\n this.#ref = obj.#ref;\n this.#alias = new Map(this.#alias.entries());\n obj.#genericLabels && (this.#genericLabels = [...obj.#genericLabels]);\n this.#nestedGenerics = obj.#nestedGenerics.map((item) => [...item]);\n this.#target = obj.#target;\n this.#isGeneric = obj.#isGeneric;\n this.#isCollection = obj.#isCollection;\n this.#ref = obj.#ref;\n\n super.set(\"type\", obj.get(\"type\"));\n }\n\n return this;\n }\n\n set(key: string, value: any): this {\n if (key in this) {\n isFunction((this as any)[key]) && (this as any)[key](value);\n } else {\n super.set(key, value);\n }\n\n return this;\n }\n\n /**\n * Return the itemSchema computed type.\n * If the type is a function used for recursive model,\n * the function will be called to get the right type.\n */\n getComputedType(): any {\n return getComputedType(this.#target);\n }\n\n getComputedItemType(): any {\n return this.#itemSchema ? this.#itemSchema.getComputedType() : this.getComputedType();\n }\n\n /**\n * Return the Json type as string\n */\n getJsonType(): string | string[] {\n return this.get(\"type\") || getJsonType(this.getComputedType());\n }\n\n getTarget() {\n return this.#target;\n }\n\n /**\n * Get the symbolic name of the entity\n */\n getName() {\n return this.get(\"name\") || (this.#target ? nameOf(classOf(this.getComputedType())) : \"\");\n }\n\n clone() {\n return new JsonSchema(this);\n }\n}\n"]}
@@ -4,6 +4,9 @@ exports.SpecTypes = void 0;
4
4
  var SpecTypes;
5
5
  (function (SpecTypes) {
6
6
  SpecTypes["JSON"] = "jsonschema";
7
+ /**
8
+ * @deprecated
9
+ */
7
10
  SpecTypes["SWAGGER"] = "swagger2";
8
11
  SpecTypes["OPENAPI"] = "openapi3";
9
12
  })(SpecTypes = exports.SpecTypes || (exports.SpecTypes = {}));
@@ -1 +1 @@
1
- {"version":3,"file":"SpecTypes.js","sourceRoot":"","sources":["../../../src/domain/SpecTypes.ts"],"names":[],"mappings":";;;AAAA,IAAY,SAIX;AAJD,WAAY,SAAS;IACnB,gCAAmB,CAAA;IACnB,iCAAoB,CAAA;IACpB,iCAAoB,CAAA;AACtB,CAAC,EAJW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAIpB","sourcesContent":["export enum SpecTypes {\n JSON = \"jsonschema\",\n SWAGGER = \"swagger2\",\n OPENAPI = \"openapi3\"\n}\n"]}
1
+ {"version":3,"file":"SpecTypes.js","sourceRoot":"","sources":["../../../src/domain/SpecTypes.ts"],"names":[],"mappings":";;;AAAA,IAAY,SAOX;AAPD,WAAY,SAAS;IACnB,gCAAmB,CAAA;IACnB;;OAEG;IACH,iCAAoB,CAAA;IACpB,iCAAoB,CAAA;AACtB,CAAC,EAPW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAOpB","sourcesContent":["export enum SpecTypes {\n JSON = \"jsonschema\",\n /**\n * @deprecated\n */\n SWAGGER = \"swagger2\",\n OPENAPI = \"openapi3\"\n}\n"]}
@@ -31,9 +31,9 @@ function get(model, options, cb) {
31
31
  * @param model
32
32
  * @param options
33
33
  */
34
- function getSpec(model, options = { specType: SpecTypes_1.SpecTypes.SWAGGER }) {
34
+ function getSpec(model, options = {}) {
35
35
  if (!options.specType) {
36
- options.specType = SpecTypes_1.SpecTypes.SWAGGER;
36
+ options.specType = SpecTypes_1.SpecTypes.OPENAPI;
37
37
  }
38
38
  options = {
39
39
  ...options,
@@ -43,7 +43,7 @@ function getSpec(model, options = { specType: SpecTypes_1.SpecTypes.SWAGGER }) {
43
43
  };
44
44
  return get(model, options, () => {
45
45
  const store = (0, getJsonEntityStore_1.getJsonEntityStore)(model);
46
- const { specType = SpecTypes_1.SpecTypes.SWAGGER, schemas = {}, paths = {}, rootPath = "/", tags = [] } = options;
46
+ const { specType = SpecTypes_1.SpecTypes.OPENAPI, schemas = {}, paths = {}, rootPath = "/", tags = [] } = options;
47
47
  const ctrlPath = store.path;
48
48
  const defaultTags = (0, core_1.cleanObject)({
49
49
  name: store.schema.getName(),
@@ -1 +1 @@
1
- {"version":3,"file":"getSpec.js","sourceRoot":"","sources":["../../../src/utils/getSpec.ts"],"names":[],"mappings":";;;AAAA,qCAAqD;AAErD,mDAA8C;AAE9C,2CAAsC;AACtC,6DAAwD;AACxD,+DAA0D;AAC1D,qDAAgD;AAChD,iEAA4D;AAoC5D;;GAEG;AACH,MAAM,MAAM,GAAqC,IAAI,GAAG,EAAE,CAAC;AAE3D;;GAEG;AACH,SAAS,GAAG,CAAC,KAAgB,EAAE,OAAY,EAAE,EAAO;IAClD,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;QACtB,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;KAC9B;IAED,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAE,CAAC;IACjC,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IA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,0BAgEC","sourcesContent":["import {cleanObject, Type, uniqBy} from \"@tsed/core\";\nimport {OpenSpec2, OpenSpec3} from \"@tsed/openspec\";\nimport {SpecTypes} from \"../domain/SpecTypes\";\nimport {JsonSchemaOptions} from \"../interfaces\";\nimport {buildPath} from \"./buildPath\";\nimport {getJsonEntityStore} from \"./getJsonEntityStore\";\nimport {getOperationsStores} from \"./getOperationsStores\";\nimport {mergeOperation} from \"./mergeOperation\";\nimport {operationIdFormatter} from \"./operationIdFormatter\";\n\nexport interface SpecSerializerOptions extends JsonSchemaOptions {\n specType?: SpecTypes.SWAGGER | SpecTypes.OPENAPI;\n /**\n * Paths\n */\n paths?: any;\n /**\n * Root path. This paths will be added to all generated paths Object.\n */\n rootPath?: string;\n /**\n * A function to generate the operationId.\n */\n operationIdFormatter?: (name: string, propertyKey: string, path: string) => string;\n /**\n * A pattern to generate the operationId.\n */\n operationIdPattern?: string;\n}\n\nexport interface OS3SpecSerializerOptions extends SpecSerializerOptions {\n /**\n * Define Spec types level\n */\n specType: SpecTypes.OPENAPI;\n}\n\nexport interface OS2SpecSerializerOptions extends SpecSerializerOptions {\n /**\n * Define Spec types level\n */\n specType: SpecTypes.SWAGGER;\n}\n\n/**\n * @ignore\n */\nconst caches: Map<Type<any>, Map<string, any>> = new Map();\n\n/**\n * @ignore\n */\nfunction get(model: Type<any>, options: any, cb: any) {\n if (!caches.has(model)) {\n caches.set(model, new Map());\n }\n\n const cache = caches.get(model)!;\n const key = JSON.stringify(options);\n\n if (!cache.has(key)) {\n cache.set(key, cb());\n }\n\n return cache.get(key);\n}\n\n/**\n * Return the swagger or open spec for the given class.\n * @param model\n * @param options\n */\nexport function getSpec(model: Type<any>, options: OS2SpecSerializerOptions): Partial<OpenSpec2>;\nexport function getSpec(model: Type<any>): Partial<OpenSpec2>;\nexport function getSpec(model: Type<any>, options: SpecSerializerOptions): Partial<OpenSpec2>;\n/**\n * Return the swagger or open spec for the given class.\n * @param model\n * @param options\n */\nexport function getSpec(model: Type<any>, options: OS3SpecSerializerOptions): Partial<OpenSpec3>;\n/**\n * Return the swagger or open spec for the given class.\n * @param model\n * @param options\n */\nexport function getSpec(model: Type<any>, options: SpecSerializerOptions = {specType: SpecTypes.SWAGGER}): Partial<OpenSpec2 | OpenSpec3> {\n if (!options.specType) {\n options.specType = SpecTypes.SWAGGER;\n }\n\n options = {\n ...options,\n operationIdFormatter: options.operationIdFormatter || operationIdFormatter(options.operationIdPattern),\n root: false,\n specType: options.specType\n };\n\n return get(model, options, () => {\n const store = getJsonEntityStore(model);\n const {specType = SpecTypes.SWAGGER, schemas = {}, paths = {}, rootPath = \"/\", tags = []} = options;\n const ctrlPath = store.path;\n const defaultTags = cleanObject({\n name: store.schema.getName(),\n description: store.schema.get(\"description\")\n });\n\n const specJson: any = {paths};\n\n getOperationsStores(model).forEach((operationStore) => {\n if (operationStore.store.get(\"hidden\")) {\n return;\n }\n\n const operation = operationStore.operation!.toJSON({...options, specType, schemas});\n\n operationStore.operation!.operationPaths.forEach(({path, method}: {path: string; method: string}) => {\n if (method) {\n mergeOperation(specJson, operation, {\n rootPath: buildPath(rootPath + ctrlPath),\n path,\n method,\n defaultTags,\n tags,\n specType,\n operationId: (path: string) =>\n options.operationIdFormatter!(\n operationStore.parent.schema.get(\"name\") || operationStore.parent.targetName,\n operationStore.propertyName,\n path\n )\n });\n }\n });\n });\n\n specJson.tags = uniqBy(tags, \"name\");\n\n if (Object.keys(schemas).length) {\n if (specType === SpecTypes.OPENAPI) {\n specJson.components = {\n schemas\n };\n } else {\n specJson.definitions = schemas;\n }\n }\n\n return specJson;\n });\n}\n"]}
1
+ {"version":3,"file":"getSpec.js","sourceRoot":"","sources":["../../../src/utils/getSpec.ts"],"names":[],"mappings":";;;AAAA,qCAAqD;AAErD,mDAA8C;AAE9C,2CAAsC;AACtC,6DAAwD;AACxD,+DAA0D;AAC1D,qDAAgD;AAChD,iEAA4D;AAoC5D;;GAEG;AACH,MAAM,MAAM,GAAqC,IAAI,GAAG,E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AC,CAAC;QAErC,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE;YAC/B,IAAI,QAAQ,KAAK,qBAAS,CAAC,OAAO,EAAE;gBAClC,QAAQ,CAAC,UAAU,GAAG;oBACpB,OAAO;iBACR,CAAC;aACH;iBAAM;gBACL,QAAQ,CAAC,WAAW,GAAG,OAAO,CAAC;aAChC;SACF;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC;AAhED,0BAgEC","sourcesContent":["import {cleanObject, Type, uniqBy} from \"@tsed/core\";\nimport {OpenSpec2, OpenSpec3} from \"@tsed/openspec\";\nimport {SpecTypes} from \"../domain/SpecTypes\";\nimport {JsonSchemaOptions} from \"../interfaces\";\nimport {buildPath} from \"./buildPath\";\nimport {getJsonEntityStore} from \"./getJsonEntityStore\";\nimport {getOperationsStores} from \"./getOperationsStores\";\nimport {mergeOperation} from \"./mergeOperation\";\nimport {operationIdFormatter} from \"./operationIdFormatter\";\n\nexport interface SpecSerializerOptions extends JsonSchemaOptions {\n specType?: SpecTypes.SWAGGER | SpecTypes.OPENAPI;\n /**\n * Paths\n */\n paths?: any;\n /**\n * Root path. This paths will be added to all generated paths Object.\n */\n rootPath?: string;\n /**\n * A function to generate the operationId.\n */\n operationIdFormatter?: (name: string, propertyKey: string, path: string) => string;\n /**\n * A pattern to generate the operationId.\n */\n operationIdPattern?: string;\n}\n\nexport interface OS3SpecSerializerOptions extends SpecSerializerOptions {\n /**\n * Define Spec types level\n */\n specType: SpecTypes.OPENAPI;\n}\n\nexport interface OS2SpecSerializerOptions extends SpecSerializerOptions {\n /**\n * Define Spec types level\n */\n specType: SpecTypes.SWAGGER;\n}\n\n/**\n * @ignore\n */\nconst caches: Map<Type<any>, Map<string, any>> = new Map();\n\n/**\n * @ignore\n */\nfunction get(model: Type<any>, options: any, cb: any) {\n if (!caches.has(model)) {\n caches.set(model, new Map());\n }\n\n const cache = caches.get(model)!;\n const key = JSON.stringify(options);\n\n if (!cache.has(key)) {\n cache.set(key, cb());\n }\n\n return cache.get(key);\n}\n\n/**\n * Return the swagger or open spec for the given class.\n * @param model\n * @param options\n */\nexport function getSpec(model: Type<any>, options: OS2SpecSerializerOptions): Partial<OpenSpec2>;\nexport function getSpec(model: Type<any>): Partial<OpenSpec2>;\nexport function getSpec(model: Type<any>, options: SpecSerializerOptions): Partial<OpenSpec2>;\n/**\n * Return the swagger or open spec for the given class.\n * @param model\n * @param options\n */\nexport function getSpec(model: Type<any>, options: OS3SpecSerializerOptions): Partial<OpenSpec3>;\n/**\n * Return the swagger or open spec for the given class.\n * @param model\n * @param options\n */\nexport function getSpec(model: Type<any>, options: SpecSerializerOptions = {}): Partial<OpenSpec2 | OpenSpec3> {\n if (!options.specType) {\n options.specType = SpecTypes.OPENAPI;\n }\n\n options = {\n ...options,\n operationIdFormatter: options.operationIdFormatter || operationIdFormatter(options.operationIdPattern),\n root: false,\n specType: options.specType\n };\n\n return get(model, options, () => {\n const store = getJsonEntityStore(model);\n const {specType = SpecTypes.OPENAPI, schemas = {}, paths = {}, rootPath = \"/\", tags = []} = options;\n const ctrlPath = store.path;\n const defaultTags = cleanObject({\n name: store.schema.getName(),\n description: store.schema.get(\"description\")\n });\n\n const specJson: any = {paths};\n\n getOperationsStores(model).forEach((operationStore) => {\n if (operationStore.store.get(\"hidden\")) {\n return;\n }\n\n const operation = operationStore.operation!.toJSON({...options, specType, schemas});\n\n operationStore.operation!.operationPaths.forEach(({path, method}: {path: string; method: string}) => {\n if (method) {\n mergeOperation(specJson, operation, {\n rootPath: buildPath(rootPath + ctrlPath),\n path,\n method,\n defaultTags,\n tags,\n specType,\n operationId: (path: string) =>\n options.operationIdFormatter!(\n operationStore.parent.schema.get(\"name\") || operationStore.parent.targetName,\n operationStore.propertyName,\n path\n )\n });\n }\n });\n });\n\n specJson.tags = uniqBy(tags, \"name\");\n\n if (Object.keys(schemas).length) {\n if (specType === SpecTypes.OPENAPI) {\n specJson.components = {\n schemas\n };\n } else {\n specJson.definitions = schemas;\n }\n }\n\n return specJson;\n });\n}\n"]}
@@ -3,26 +3,45 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.mapNullableType = void 0;
4
4
  const core_1 = require("@tsed/core");
5
5
  const SpecTypes_1 = require("../domain/SpecTypes");
6
+ function hasNullable(obj) {
7
+ return obj.oneOf.find((o) => o.type === "null");
8
+ }
6
9
  function mapNullableType(obj, schema, options) {
7
- if (!schema.nullable) {
10
+ if (!schema.isNullable) {
8
11
  return obj;
9
12
  }
10
- let types = [].concat(obj.type).filter((type) => type !== "null");
13
+ let types = [].concat(obj.type).filter(Boolean);
11
14
  switch (options.specType) {
12
15
  case SpecTypes_1.SpecTypes.SWAGGER:
13
- case SpecTypes_1.SpecTypes.JSON:
14
- obj.type = ["null", ...types];
16
+ if (!obj.allOf && !obj.$ref) {
17
+ obj.type = (0, core_1.uniq)(["null", ...types]);
18
+ }
15
19
  break;
16
- case SpecTypes_1.SpecTypes.OPENAPI:
17
- if (types.length > 1) {
18
- obj.oneOf = types.map((type) => {
19
- return (0, core_1.cleanObject)({ type, nullable: true });
20
- }, []);
20
+ default:
21
+ case SpecTypes_1.SpecTypes.JSON:
22
+ if (obj.oneOf) {
23
+ if (!hasNullable(obj)) {
24
+ obj.oneOf.unshift({
25
+ type: "null"
26
+ });
27
+ }
21
28
  }
22
29
  else {
23
- obj.type = types[0];
24
- obj.nullable = true;
30
+ obj.type = (0, core_1.uniq)(["null", ...types]);
25
31
  }
32
+ break;
33
+ case SpecTypes_1.SpecTypes.OPENAPI:
34
+ obj.nullable = true;
35
+ if (!obj.oneOf) {
36
+ if (types.length > 1) {
37
+ obj.oneOf = types.map((type) => ({ type }));
38
+ delete obj.type;
39
+ }
40
+ else {
41
+ obj.type = types[0];
42
+ }
43
+ }
44
+ break;
26
45
  }
27
46
  return obj;
28
47
  }
@@ -1 +1 @@
1
- {"version":3,"file":"mapNullableType.js","sourceRoot":"","sources":["../../../src/utils/mapNullableType.ts"],"names":[],"mappings":";;;AAAA,qCAAuC;AAEvC,mDAA8C;AAG9C,SAAgB,eAAe,CAAC,GAAQ,EAAE,MAAkB,EAAE,OAA0B;IACtF,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE;QACpB,OAAO,GAAG,CAAC;KACZ;IAED,IAAI,KAAK,GAAa,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC;IAEpF,QAAQ,OAAO,CAAC,QAAQ,EAAE;QACxB,KAAK,qBAAS,CAAC,OAAO,CAAC;QACvB,KAAK,qBAAS,CAAC,IAAI;YACjB,GAAG,CAAC,IAAI,GAAG,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC;YAC9B,MAAM;QAER,KAAK,qBAAS,CAAC,OAAO;YACpB,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;gBACpB,GAAG,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAY,EAAE,EAAE;oBACrC,OAAO,IAAA,kBAAW,EAAC,EAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAC;gBAC7C,CAAC,EAAE,EAAE,CAAC,CAAC;aACR;iBAAM;gBACL,GAAG,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;gBACpB,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC;aACrB;KACJ;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAzBD,0CAyBC","sourcesContent":["import {cleanObject} from \"@tsed/core\";\nimport type {JsonSchema} from \"../domain/JsonSchema\";\nimport {SpecTypes} from \"../domain/SpecTypes\";\nimport type {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\n\nexport function mapNullableType(obj: any, schema: JsonSchema, options: JsonSchemaOptions) {\n if (!schema.nullable) {\n return obj;\n }\n\n let types: string[] = [].concat(obj.type).filter((type: string) => type !== \"null\");\n\n switch (options.specType) {\n case SpecTypes.SWAGGER:\n case SpecTypes.JSON:\n obj.type = [\"null\", ...types];\n break;\n\n case SpecTypes.OPENAPI:\n if (types.length > 1) {\n obj.oneOf = types.map((type: string) => {\n return cleanObject({type, nullable: true});\n }, []);\n } else {\n obj.type = types[0];\n obj.nullable = true;\n }\n }\n\n return obj;\n}\n"]}
1
+ {"version":3,"file":"mapNullableType.js","sourceRoot":"","sources":["../../../src/utils/mapNullableType.ts"],"names":[],"mappings":";;;AAAA,qCAAgC;AAEhC,mDAA8C;AAG9C,SAAS,WAAW,CAAC,GAAQ;IAC3B,OAAO,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC;AACvD,CAAC;AAED,SAAgB,eAAe,CAAC,GAAQ,EAAE,MAAkB,EAAE,OAA0B;IACtF,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE;QACtB,OAAO,GAAG,CAAC;KACZ;IACD,IAAI,KAAK,GAAa,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAE1D,QAAQ,OAAO,CAAC,QAAQ,EAAE;QACxB,KAAK,qBAAS,CAAC,OAAO;YACpB,IAAI,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE;gBAC3B,GAAG,CAAC,IAAI,GAAG,IAAA,WAAI,EAAC,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC;aACrC;YACD,MAAM;QACR,QAAQ;QACR,KAAK,qBAAS,CAAC,IAAI;YACjB,IAAI,GAAG,CAAC,KAAK,EAAE;gBACb,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE;oBACrB,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC;wBAChB,IAAI,EAAE,MAAM;qBACb,CAAC,CAAC;iBACJ;aACF;iBAAM;gBACL,GAAG,CAAC,IAAI,GAAG,IAAA,WAAI,EAAC,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC;aACrC;YACD,MAAM;QAER,KAAK,qBAAS,CAAC,OAAO;YACpB,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC;YAEpB,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE;gBACd,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;oBACpB,GAAG,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAC,IAAI,EAAC,CAAC,CAAC,CAAC;oBAC1C,OAAO,GAAG,CAAC,IAAI,CAAC;iBACjB;qBAAM;oBACL,GAAG,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;iBACrB;aACF;YACD,MAAM;KACT;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAxCD,0CAwCC","sourcesContent":["import {uniq} from \"@tsed/core\";\nimport type {JsonSchema} from \"../domain/JsonSchema\";\nimport {SpecTypes} from \"../domain/SpecTypes\";\nimport type {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\n\nfunction hasNullable(obj: any) {\n return obj.oneOf.find((o: any) => o.type === \"null\");\n}\n\nexport function mapNullableType(obj: any, schema: JsonSchema, options: JsonSchemaOptions) {\n if (!schema.isNullable) {\n return obj;\n }\n let types: string[] = [].concat(obj.type).filter(Boolean);\n\n switch (options.specType) {\n case SpecTypes.SWAGGER:\n if (!obj.allOf && !obj.$ref) {\n obj.type = uniq([\"null\", ...types]);\n }\n break;\n default:\n case SpecTypes.JSON:\n if (obj.oneOf) {\n if (!hasNullable(obj)) {\n obj.oneOf.unshift({\n type: \"null\"\n });\n }\n } else {\n obj.type = uniq([\"null\", ...types]);\n }\n break;\n\n case SpecTypes.OPENAPI:\n obj.nullable = true;\n\n if (!obj.oneOf) {\n if (types.length > 1) {\n obj.oneOf = types.map((type) => ({type}));\n delete obj.type;\n } else {\n obj.type = types[0];\n }\n }\n break;\n }\n\n return obj;\n}\n"]}
@@ -30,29 +30,32 @@ function createRef(name, schema, options) {
30
30
  const ref = {
31
31
  $ref: `${host}/${name}`
32
32
  };
33
- const nullable = schema.nullable;
34
- const readOnly = schema.get ? schema.get("readOnly") : undefined;
35
- if (nullable || readOnly) {
33
+ const nullable = schema.isNullable;
34
+ const readOnly = schema.isReadOnly;
35
+ const writeOnly = schema.isWriteOnly;
36
+ if (nullable || readOnly || writeOnly) {
36
37
  switch (options.specType) {
37
38
  case SpecTypes_1.SpecTypes.OPENAPI:
38
39
  return (0, core_1.cleanObject)({
39
40
  nullable: nullable ? true : undefined,
40
41
  readOnly: readOnly ? true : undefined,
41
- allOf: [ref]
42
+ writeOnly: writeOnly ? true : undefined,
43
+ oneOf: [ref]
42
44
  });
43
45
  case SpecTypes_1.SpecTypes.JSON:
44
46
  return (0, core_1.cleanObject)({
45
47
  readOnly,
46
- oneOf: [nullable && { type: "null" }, ref].filter(Boolean)
48
+ writeOnly,
49
+ oneOf: [ref]
47
50
  });
48
- case SpecTypes_1.SpecTypes.SWAGGER: // unsupported
49
- if (readOnly) {
50
- return {
51
+ case SpecTypes_1.SpecTypes.SWAGGER: // TODO unsupported feature
52
+ if (readOnly || writeOnly) {
53
+ return (0, core_1.cleanObject)({
51
54
  readOnly,
55
+ writeOnly,
52
56
  allOf: [ref]
53
- };
57
+ });
54
58
  }
55
- break;
56
59
  }
57
60
  }
58
61
  return ref;
@@ -1 +1 @@
1
- {"version":3,"file":"ref.js","sourceRoot":"","sources":["../../../src/utils/ref.ts"],"names":[],"mappings":";;;AAAA,6CAAuC;AAEvC,mDAA8C;AAE9C,qCAAuC;AAEvC;;;GAGG;AACH,SAAS,OAAO,CAAC,OAA0B;IACzC,MAAM,EAAC,IAAI,GAAG,KAAK,OAAO,CAAC,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,oBAAoB,C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I,EAAC,IAAI,EAAE,MAAM,EAAC,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;iBACzD,CAAC,CAAC;YACL,KAAK,qBAAS,CAAC,OAAO,EAAE,cAAc;gBACpC,IAAI,QAAQ,EAAE;oBACZ,OAAO;wBACL,QAAQ;wBACR,KAAK,EAAE,CAAC,GAAG,CAAC;qBACb,CAAC;iBACH;gBACD,MAAM;SACT;KACF;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAlCD,8BAkCC;AAED;;GAEG;AACH,SAAgB,KAAK,CAAC,KAAiB,EAAE,MAAW,EAAE,OAA0B;IAC9E,MAAM,IAAI,GAAG,aAAa,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,OAAO,CAAC,CAAC;IAErD,OAAO,CAAC,OAAQ,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,GAAG,MAAM,CAAC;IAE3C,OAAO,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;AACzC,CAAC;AAND,sBAMC","sourcesContent":["import {pascalCase} from \"pascal-case\";\nimport type {JsonSchema} from \"../domain/JsonSchema\";\nimport {SpecTypes} from \"../domain/SpecTypes\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {cleanObject} from \"@tsed/core\";\n\n/**\n * ignore\n * @param options\n */\nfunction getHost(options: JsonSchemaOptions) {\n const {host = `#/${options.specType === \"openapi3\" ? \"components/schemas\" : \"definitions\"}`} = options;\n\n return host;\n}\n\n/**\n * @ignore\n */\nexport function createRefName(name: string, options: JsonSchemaOptions) {\n if (options.groups && options.groups.length) {\n return pascalCase(`${name} ${options.groups.join(\" \")}`);\n }\n\n return name;\n}\n\n/**\n * @ignore\n */\nexport function createRef(name: string, schema: JsonSchema, options: JsonSchemaOptions) {\n const host = getHost(options);\n const ref = {\n $ref: `${host}/${name}`\n };\n\n const nullable = schema.nullable;\n const readOnly = schema.get ? schema.get(\"readOnly\") : undefined;\n\n if (nullable || readOnly) {\n switch (options.specType) {\n case SpecTypes.OPENAPI:\n return cleanObject({\n nullable: nullable ? true : undefined,\n readOnly: readOnly ? true : undefined,\n allOf: [ref]\n });\n case SpecTypes.JSON:\n return cleanObject({\n readOnly,\n oneOf: [nullable && {type: \"null\"}, ref].filter(Boolean)\n });\n case SpecTypes.SWAGGER: // unsupported\n if (readOnly) {\n return {\n readOnly,\n allOf: [ref]\n };\n }\n break;\n }\n }\n\n return ref;\n}\n\n/**\n * @ignore\n */\nexport function toRef(value: JsonSchema, schema: any, options: JsonSchemaOptions) {\n const name = createRefName(value.getName(), options);\n\n options.schemas![value.getName()] = schema;\n\n return createRef(name, value, options);\n}\n"]}
1
+ {"version":3,"file":"ref.js","sourceRoot":"","sources":["../../../src/utils/ref.ts"],"names":[],"mappings":";;;AAAA,6CAAuC;AAEvC,mDAA8C;AAE9C,qCAAuC;AAEvC;;;GAGG;AACH,SAAS,OAAO,CAAC,OAA0B;IACzC,MAAM,EAAC,IAAI,GAAG,KAAK,OAAO,CAAC,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,aAAa,EAAE,EAAC,GAAG,OAAO,CAAC;IAEvG,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;GAEG;AACH,SAAgB,aAAa,CAAC,IAAY,EAAE,OAA0B;IACpE,IAAI,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE;QAC3C,OAAO,IAAA,wBAAU,EAAC,GAAG,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;KAC1D;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAND,sCAMC;AAED;;GAEG;AACH,SAAgB,SAAS,CAAC,IAAY,EAAE,MAAkB,EAAE,OAA0B;IACpF,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC9B,MAAM,GAAG,GAAG;QACV,IAAI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OAAO,EAAE,CAAC,GAAG,MAAM,CAAC;IAE3C,OAAO,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;AACzC,CAAC;AAND,sBAMC","sourcesContent":["import {pascalCase} from \"pascal-case\";\nimport type {JsonSchema} from \"../domain/JsonSchema\";\nimport {SpecTypes} from \"../domain/SpecTypes\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {cleanObject} from \"@tsed/core\";\n\n/**\n * ignore\n * @param options\n */\nfunction getHost(options: JsonSchemaOptions) {\n const {host = `#/${options.specType === \"openapi3\" ? \"components/schemas\" : \"definitions\"}`} = options;\n\n return host;\n}\n\n/**\n * @ignore\n */\nexport function createRefName(name: string, options: JsonSchemaOptions) {\n if (options.groups && options.groups.length) {\n return pascalCase(`${name} ${options.groups.join(\" \")}`);\n }\n\n return name;\n}\n\n/**\n * @ignore\n */\nexport function createRef(name: string, schema: JsonSchema, options: JsonSchemaOptions) {\n const host = getHost(options);\n const ref = {\n $ref: `${host}/${name}`\n };\n\n const nullable = schema.isNullable;\n const readOnly = schema.isReadOnly;\n const writeOnly = schema.isWriteOnly;\n\n if (nullable || readOnly || writeOnly) {\n switch (options.specType) {\n case SpecTypes.OPENAPI:\n return cleanObject({\n nullable: nullable ? true : undefined,\n readOnly: readOnly ? true : undefined,\n writeOnly: writeOnly ? true : undefined,\n oneOf: [ref]\n });\n case SpecTypes.JSON:\n return cleanObject({\n readOnly,\n writeOnly,\n oneOf: [ref]\n });\n case SpecTypes.SWAGGER: // TODO unsupported feature\n if (readOnly || writeOnly) {\n return cleanObject({\n readOnly,\n writeOnly,\n allOf: [ref]\n });\n }\n }\n }\n\n return ref;\n}\n\n/**\n * @ignore\n */\nexport function toRef(value: JsonSchema, schema: any, options: JsonSchemaOptions) {\n const name = createRefName(value.getName(), options);\n\n options.schemas![value.getName()] = schema;\n\n return createRef(name, value, options);\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  import { isArray } from "@tsed/core";
2
2
  import { alterIgnore } from "../hooks/alterIgnore";
3
3
  import { execMapper, registerJsonSchemaMapper } from "../registries/JsonSchemaMapperContainer";
4
+ import { mapNullableType } from "../utils/mapNullableType";
4
5
  /**
5
6
  * Serialize Any object to a json schema
6
7
  * @param input
@@ -11,11 +12,13 @@ export function objectMapper(input, options) {
11
12
  const { specType, operationIdFormatter, root, schemas, genericTypes, nestedGenerics, useAlias, genericLabels, ...ctx } = options;
12
13
  return Object.entries(input).reduce((obj, [key, value]) => {
13
14
  if (options.withIgnoredProps !== false && !alterIgnore(value, ctx)) {
14
- // remove groups to avoid bad schema generation over children models
15
- obj[key] = execMapper("item", value, {
15
+ const opts = {
16
16
  ...options,
17
17
  groups: (input === null || input === void 0 ? void 0 : input.$forwardGroups) || (value === null || value === void 0 ? void 0 : value.$forwardGroups) ? options.groups : undefined
18
- });
18
+ };
19
+ // remove groups to avoid bad schema generation over children models
20
+ obj[key] = execMapper("item", value, opts);
21
+ obj[key] = mapNullableType(obj[key], value, opts);
19
22
  }
20
23
  return obj;
21
24
  }, isArray(input) ? [] : {});
@@ -1 +1 @@
1
- {"version":3,"file":"objectMapper.js","sourceRoot":"","sources":["../../../src/components/objectMapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAC,WAAW,EAAC,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAC,UAAU,EAAE,wBAAwB,EAAC,MAAM,yCAAyC,CAAC;AAE7F;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,KAAU,EAAE,OAA0B;IACjE,MAAM,EAAC,QAAQ,EAAE,oBAAoB,EAAE,IAAI,EAAE,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,aAAa,EAAE,GAAG,GAAG,EAAC,GAAG,OAAO,CAAC;IAE/H,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CACjC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,KAAK,CAA6B,EAAE,EAAE;QAChD,IAAI,OAAO,CAAC,gBAAgB,KAAK,KAAK,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE;YAClE,oEAAoE;YACpE,GAAG,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,KAAK,EAAE;gBACnC,GAAG,OAAO;gBACV,MAAM,EAAE,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,cAAc,MAAI,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,cAAc,CAAA,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;aACpF,CAAC,CAAC;SACJ;QAED,OAAO,GAAG,CAAC;IACb,CAAC,EACD,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CACzB,CAAC;AACJ,CAAC;AAED,wBAAwB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC","sourcesContent":["import {isArray} from \"@tsed/core\";\nimport {JsonSchema} from \"../domain/JsonSchema\";\nimport {alterIgnore} from \"../hooks/alterIgnore\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {execMapper, registerJsonSchemaMapper} from \"../registries/JsonSchemaMapperContainer\";\n\n/**\n * Serialize Any object to a json schema\n * @param input\n * @param options\n * @ignore\n */\nexport function objectMapper(input: any, options: JsonSchemaOptions) {\n const {specType, operationIdFormatter, root, schemas, genericTypes, nestedGenerics, useAlias, genericLabels, ...ctx} = options;\n\n return Object.entries(input).reduce<any>(\n (obj, [key, value]: [string, any | JsonSchema]) => {\n if (options.withIgnoredProps !== false && !alterIgnore(value, ctx)) {\n // remove groups to avoid bad schema generation over children models\n obj[key] = execMapper(\"item\", value, {\n ...options,\n groups: input?.$forwardGroups || value?.$forwardGroups ? options.groups : undefined\n });\n }\n\n return obj;\n },\n isArray(input) ? [] : {}\n );\n}\n\nregisterJsonSchemaMapper(\"object\", objectMapper);\n"]}
1
+ {"version":3,"file":"objectMapper.js","sourceRoot":"","sources":["../../../src/components/objectMapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAC,WAAW,EAAC,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAC,UAAU,EAAE,wBAAwB,EAAC,MAAM,yCAAyC,CAAC;AAC7F,OAAO,EAAC,eAAe,EAAC,MAAM,0BAA0B,CAAC;AAEzD;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,KAAU,EAAE,OAA0B;IACjE,MAAM,EAAC,QAAQ,EAAE,oBAAoB,EAAE,IAAI,EAAE,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,aAAa,EAAE,GAAG,GAAG,EAAC,GAAG,OAAO,CAAC;IAE/H,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CACjC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,KAAK,CAA6B,EAAE,EAAE;QAChD,IAAI,OAAO,CAAC,gBAAgB,KAAK,KAAK,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE;YAClE,MAAM,IAAI,GAAG;gBACX,GAAG,OAAO;gBACV,MAAM,EAAE,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,cAAc,MAAI,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,cAAc,CAAA,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;aACpF,CAAC;YACF,oEAAoE;YACpE,GAAG,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;YAC3C,GAAG,CAAC,GAAG,CAAC,GAAG,eAAe,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;SACnD;QAED,OAAO,GAAG,CAAC;IACb,CAAC,EACD,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CACzB,CAAC;AACJ,CAAC;AAED,wBAAwB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC","sourcesContent":["import {isArray} from \"@tsed/core\";\nimport {JsonSchema} from \"../domain/JsonSchema\";\nimport {alterIgnore} from \"../hooks/alterIgnore\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {execMapper, registerJsonSchemaMapper} from \"../registries/JsonSchemaMapperContainer\";\nimport {mapNullableType} from \"../utils/mapNullableType\";\n\n/**\n * Serialize Any object to a json schema\n * @param input\n * @param options\n * @ignore\n */\nexport function objectMapper(input: any, options: JsonSchemaOptions) {\n const {specType, operationIdFormatter, root, schemas, genericTypes, nestedGenerics, useAlias, genericLabels, ...ctx} = options;\n\n return Object.entries(input).reduce<any>(\n (obj, [key, value]: [string, any | JsonSchema]) => {\n if (options.withIgnoredProps !== false && !alterIgnore(value, ctx)) {\n const opts = {\n ...options,\n groups: input?.$forwardGroups || value?.$forwardGroups ? options.groups : undefined\n };\n // remove groups to avoid bad schema generation over children models\n obj[key] = execMapper(\"item\", value, opts);\n obj[key] = mapNullableType(obj[key], value, opts);\n }\n\n return obj;\n },\n isArray(input) ? [] : {}\n );\n}\n\nregisterJsonSchemaMapper(\"object\", objectMapper);\n"]}
@@ -3,8 +3,8 @@ import { mapAliasedProperties } from "../domain/JsonAliasMap";
3
3
  import { SpecTypes } from "../domain/SpecTypes";
4
4
  import { execMapper, hasMapper, registerJsonSchemaMapper } from "../registries/JsonSchemaMapperContainer";
5
5
  import { getRequiredProperties } from "../utils/getRequiredProperties";
6
- import { mapNullableType } from "../utils/mapNullableType";
7
6
  import { alterOneOf } from "../hooks/alterOneOf";
7
+ import { mapNullableType } from "../utils/mapNullableType";
8
8
  /**
9
9
  * @ignore
10
10
  */
@@ -1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OAAO,EAAQ,CAAC,CAAC;IAE7E,IAAI,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,QAAkB,CAAC,EAAE;QAC1C,GAAG,GAAG;YACJ,GAAG,GAAG;YACN,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,QAAkB,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;SAC1D,CAAC;KACH;IAED,GAAG,GAAG,qBAAqB,CAAC,GAAG,EAAE,MAAM,EAAE,EAAC,GAAG,OAAO,EAAE,QAAQ,EAAC,CAAC,CAAC;IACjE,GAAG,GAAG,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5C,GAAG,GAAG,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAEvC,OAAO,GAAG,CAAC;AACb,CAAC;AAED,wBAAwB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC","sourcesContent":["import {isObject} from \"@tsed/core\";\nimport {mapAliasedProperties} from \"../domain/JsonAliasMap\";\nimport {JsonSchema} from \"../domain/JsonSchema\";\nimport {SpecTypes} from \"../domain/SpecTypes\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {execMapper, hasMapper, registerJsonSchemaMapper} from \"../registries/JsonSchemaMapperContainer\";\nimport {getRequiredProperties} from \"../utils/getRequiredProperties\";\nimport {mapNullableType} from \"../utils/mapNullableType\";\nimport {alterOneOf} from \"../hooks/alterOneOf\";\n\n/**\n * @ignore\n */\nconst IGNORES = [\"name\", \"$required\", \"$hooks\", \"_nestedGenerics\", SpecTypes.OPENAPI, SpecTypes.SWAGGER, SpecTypes.JSON];\n/**\n * @ignore\n */\nconst IGNORES_OPENSPEC = [\"const\"];\nconst IGNORES_OS2 = [\"writeOnly\", \"readOnly\"];\n\n/**\n * @ignore\n */\nfunction isEmptyProperties(key: string, value: any) {\n return typeof value === \"object\" && [\"items\", \"properties\", \"additionalProperties\"].includes(key) && Object.keys(value).length === 0;\n}\n\n/**\n * @ignore\n */\nfunction shouldMapAlias(key: string, value: any, useAlias: boolean) {\n return typeof value === \"object\" && useAlias && [\"properties\", \"additionalProperties\"].includes(key);\n}\n\n/**\n * @ignore\n */\nfunction shouldSkipKey(key: string, {specType = SpecTypes.JSON, customKeys = false}: JsonSchemaOptions) {\n return (\n IGNORES.includes(key) ||\n (key.startsWith(\"#\") && (customKeys === false || specType !== SpecTypes.JSON)) ||\n (specType === SpecTypes.SWAGGER && IGNORES_OS2.includes(key)) ||\n (specType !== SpecTypes.JSON && IGNORES_OPENSPEC.includes(key))\n );\n}\n\nfunction isExample(key: string, value: any, options: JsonSchemaOptions) {\n return key === \"examples\" && isObject(value) && [SpecTypes.OPENAPI, SpecTypes.SWAGGER].includes(options.specType!);\n}\n\nexport function schemaMapper(schema: JsonSchema, options: JsonSchemaOptions): any {\n const {useAlias = true, schemas = {}} = options;\n options = {\n ...options,\n useAlias,\n schemas\n };\n\n let obj: any = [...schema.keys()]\n .filter((key) => !shouldSkipKey(key, options))\n .reduce((item: any, key) => {\n let value = schema.get(key);\n\n key = key.replace(/^#/, \"\");\n\n if (key === \"type\") {\n return {\n ...item,\n [key]: schema.getJsonType()\n };\n }\n\n if (isExample(key, value, options)) {\n key = \"example\";\n value = Object.values(value)[0];\n }\n\n if (value && typeof value === \"object\" && hasMapper(key)) {\n value = execMapper(key, value, options, schema);\n\n if (isEmptyProperties(key, value)) {\n return item;\n }\n\n if (shouldMapAlias(key, value, useAlias)) {\n value = mapAliasedProperties(value, schema.alias);\n }\n }\n\n return {\n ...item,\n [key]: value\n };\n }, {});\n\n if (schema.isClass) {\n obj = execMapper(\"inheritedClass\", obj, {...options, root: false, schemas, target: schema.getComputedType()});\n }\n\n obj = execMapper(\"generics\", obj, {...options, root: false, schemas} as any);\n\n if (schema.has(options.specType as string)) {\n obj = {\n ...obj,\n ...schema.get(options.specType as string).toJSON(options)\n };\n }\n\n obj = getRequiredProperties(obj, schema, {...options, useAlias});\n obj = mapNullableType(obj, schema, options);\n obj = alterOneOf(obj, schema, options);\n\n return obj;\n}\n\nregisterJsonSchemaMapper(\"schema\", schemaMapper);\n"]}
1
+ {"version":3,"file":"schemaMapper.js","sourceRoot":"","sources":["../../../src/components/schemaMapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AACpC,OAAO,EAAC,oBAAoB,EAAC,MAAM,wBAAwB,CAAC;AAE5D,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAC,UAAU,EAAE,SAAS,EAAE,wBAAwB,EAAC,MAAM,yCAAyC,CAAC;AACxG,OAAO,EAAC,qBAAqB,EAAC,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAC,UAAU,EAAC,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAC,eAAe,EAAC,MAAM,0BAA0B,CAAC;AAEzD;;GAEG;AACH,MAAM,OAAO,GAAG,CAAC,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,iBAAiB,EAAE,SAAS,CAAC,OAAO,EAAE,SAAS,CAAC,OAAO,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;AACzH;;GAEG;AACH,MAAM,gBAAgB,GAAG,CAAC,OAAO,CAAC,CAAC;AACnC,MAAM,WAAW,GAAG,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;AAE9C;;GAEG;AACH,SAAS,iBAAiB,CAAC,GAAW,EAAE,KAAU;IAChD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,OAAO,EAAE,YAAY,EAAE,sBAAsB,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;AACvI,CAAC;AAED;;GAEG;AACH,SAAS,cAAc,CAAC,GAAW,EAAE,KAAU,EAAE,QAAiB;IAChE,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI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AAG,GAAG,UAAU,CAAC,UAAU,EAAE,GAAG,EAAE,EAAC,GAAG,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAQ,CAAC,CAAC;IAE7E,IAAI,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,QAAkB,CAAC,EAAE;QAC1C,GAAG,GAAG;YACJ,GAAG,GAAG;YACN,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,QAAkB,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;SAC1D,CAAC;KACH;IAED,GAAG,GAAG,qBAAqB,CAAC,GAAG,EAAE,MAAM,EAAE,EAAC,GAAG,OAAO,EAAE,QAAQ,EAAC,CAAC,CAAC;IACjE,GAAG,GAAG,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5C,GAAG,GAAG,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAEvC,OAAO,GAAG,CAAC;AACb,CAAC;AAED,wBAAwB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC","sourcesContent":["import {isObject} from \"@tsed/core\";\nimport {mapAliasedProperties} from \"../domain/JsonAliasMap\";\nimport {JsonSchema} from \"../domain/JsonSchema\";\nimport {SpecTypes} from \"../domain/SpecTypes\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {execMapper, hasMapper, registerJsonSchemaMapper} from \"../registries/JsonSchemaMapperContainer\";\nimport {getRequiredProperties} from \"../utils/getRequiredProperties\";\nimport {alterOneOf} from \"../hooks/alterOneOf\";\nimport {mapNullableType} from \"../utils/mapNullableType\";\n\n/**\n * @ignore\n */\nconst IGNORES = [\"name\", \"$required\", \"$hooks\", \"_nestedGenerics\", SpecTypes.OPENAPI, SpecTypes.SWAGGER, SpecTypes.JSON];\n/**\n * @ignore\n */\nconst IGNORES_OPENSPEC = [\"const\"];\nconst IGNORES_OS2 = [\"writeOnly\", \"readOnly\"];\n\n/**\n * @ignore\n */\nfunction isEmptyProperties(key: string, value: any) {\n return typeof value === \"object\" && [\"items\", \"properties\", \"additionalProperties\"].includes(key) && Object.keys(value).length === 0;\n}\n\n/**\n * @ignore\n */\nfunction shouldMapAlias(key: string, value: any, useAlias: boolean) {\n return typeof value === \"object\" && useAlias && [\"properties\", \"additionalProperties\"].includes(key);\n}\n\n/**\n * @ignore\n */\nfunction shouldSkipKey(key: string, {specType = SpecTypes.JSON, customKeys = false}: JsonSchemaOptions) {\n return (\n IGNORES.includes(key) ||\n (key.startsWith(\"#\") && (customKeys === false || specType !== SpecTypes.JSON)) ||\n (specType === SpecTypes.SWAGGER && IGNORES_OS2.includes(key)) ||\n (specType !== SpecTypes.JSON && IGNORES_OPENSPEC.includes(key))\n );\n}\n\nfunction isExample(key: string, value: any, options: JsonSchemaOptions) {\n return key === \"examples\" && isObject(value) && [SpecTypes.OPENAPI, SpecTypes.SWAGGER].includes(options.specType!);\n}\n\nexport function schemaMapper(schema: JsonSchema, options: JsonSchemaOptions): any {\n const {useAlias = true, schemas = {}} = options;\n options = {\n ...options,\n useAlias,\n schemas\n };\n\n let obj: any = [...schema.keys()]\n .filter((key) => !shouldSkipKey(key, options))\n .reduce((item: any, key) => {\n let value = schema.get(key);\n\n key = key.replace(/^#/, \"\");\n\n if (key === \"type\") {\n return {\n ...item,\n [key]: schema.getJsonType()\n };\n }\n\n if (isExample(key, value, options)) {\n key = \"example\";\n value = Object.values(value)[0];\n }\n\n if (value && typeof value === \"object\" && hasMapper(key)) {\n value = execMapper(key, value, options, schema);\n\n if (isEmptyProperties(key, value)) {\n return item;\n }\n\n if (shouldMapAlias(key, value, useAlias)) {\n value = mapAliasedProperties(value, schema.alias);\n }\n }\n\n return {\n ...item,\n [key]: value\n };\n }, {});\n\n if (schema.isClass) {\n obj = execMapper(\"inheritedClass\", obj, {...options, root: false, schemas, target: schema.getComputedType()});\n }\n\n obj = execMapper(\"generics\", obj, {...options, root: false, schemas} as any);\n\n if (schema.has(options.specType as string)) {\n obj = {\n ...obj,\n ...schema.get(options.specType as string).toJSON(options)\n };\n }\n\n obj = getRequiredProperties(obj, schema, {...options, useAlias});\n obj = mapNullableType(obj, schema, options);\n obj = alterOneOf(obj, schema, options);\n\n return obj;\n}\n\nregisterJsonSchemaMapper(\"schema\", schemaMapper);\n"]}
@@ -235,16 +235,12 @@ function buildSchemaFromBodyParameters(parameters, options) {
235
235
  refs.push(jsonParameter);
236
236
  }
237
237
  });
238
- if (propsLength) {
239
- schema.type("object");
240
- return { schema: schema.toJSON(options), required: false, ...props };
241
- }
242
- if (refs.length === 1) {
243
- return refs[0];
244
- }
245
- if (refs.length > 0) {
246
- schema.allOf(refs);
238
+ if (!propsLength) {
239
+ if (refs.length === 1) {
240
+ return refs[0];
241
+ }
247
242
  }
243
+ schema.type("object");
248
244
  return { schema: schema.toJSON(options), required: false, ...props };
249
245
  }
250
246
  //# sourceMappingURL=JsonOperation.js.map