@tsed/schema 8.26.0 → 8.26.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.
@@ -29,7 +29,6 @@ function shouldMapAlias(key, value, useAlias) {
29
29
  */
30
30
  function shouldSkipKey(key, { specType = SpecTypes.JSON, customKeys = false }) {
31
31
  return (IGNORES.includes(key) ||
32
- key.startsWith("x-") ||
33
32
  (key.startsWith("#") && (!customKeys || specType !== SpecTypes.JSON)) ||
34
33
  (specType !== SpecTypes.JSON && IGNORES_OPENSPEC.includes(key)));
35
34
  }
@@ -29,12 +29,11 @@ import { Returns } from "./returns.js";
29
29
  * @param name
30
30
  */
31
31
  export function InFile(name) {
32
- return (...args) => {
33
- const [target, propertyKey, index] = args;
32
+ return (target, propertyKey, index) => {
34
33
  const multiple = Metadata.getParamTypes(target, propertyKey)[index] === Array;
35
34
  name = (typeof name === "object" ? undefined : name);
36
35
  const expression = [name, !multiple && "0"].filter(Boolean).join(".");
37
36
  const decorators = useDecorators(In(JsonParameterTypes.FILES), Name(expression), useMethodDecorators(Returns(400).Description(`<File too long | Too many parts | Too many files | Field name too long | Field value too long | Too many fields | Unexpected field> [fieldName] Example: File too long file1`), Consumes("multipart/form-data")));
38
- decorators(...args);
37
+ decorators(target, propertyKey, index);
39
38
  };
40
39
  }
@@ -32,6 +32,7 @@ class ReturnDecoratorContext extends DecoratorContext {
32
32
  "location",
33
33
  "binary"
34
34
  ];
35
+ this.hasOfTypes = false;
35
36
  this.model(model);
36
37
  this.status(status);
37
38
  }
@@ -199,10 +199,12 @@ let JsonMethodStore = class JsonMethodStore extends JsonEntityStore {
199
199
  return deepMerge(ctrlValue, this.store.get(key));
200
200
  }
201
201
  getParamTypes() {
202
- return [...this.children.values()].reduce((obj, item) => ({
203
- ...obj,
204
- [item.paramType]: true
205
- }), {});
202
+ return [...this.children.values()].reduce((obj, item) => {
203
+ if (item.paramType) {
204
+ obj[item.paramType] = true;
205
+ }
206
+ return obj;
207
+ }, {});
206
208
  }
207
209
  build() {
208
210
  this.parent.children.set(this.propertyName, this);
@@ -63,6 +63,7 @@ export class JsonMethodPath extends JsonMap {
63
63
  * @public
64
64
  */
65
65
  export class JsonOperation extends JsonMap {
66
+ // TODO check this after migration
66
67
  #status;
67
68
  #redirection;
68
69
  constructor(obj = {}) {
@@ -35,6 +35,7 @@ export class JsonResponse extends JsonMap {
35
35
  constructor(obj = {}) {
36
36
  super(obj);
37
37
  this.$kind = "operationResponse";
38
+ this.status = 200;
38
39
  this.content(obj.content || {});
39
40
  }
40
41
  description(description) {
@@ -1458,6 +1458,20 @@ export class JsonSchema extends Map {
1458
1458
  return item;
1459
1459
  }
1460
1460
  mapGenerics(jsonSchema, generics) {
1461
+ if (!(jsonSchema instanceof JsonSchema)) {
1462
+ console.warn("[@tsed/schema] The model likely contains an invalid generic declaration. " +
1463
+ "A JsonSchema instance was expected, but a different value was resolved. " +
1464
+ "Check your GenericOf/Nested declaration (or functional API usage).", {
1465
+ context: {
1466
+ schemaName: this.getName(),
1467
+ propertyKey: this.getPropertyKey(),
1468
+ target: nameOf(this.getTarget())
1469
+ },
1470
+ generics,
1471
+ resolvedValue: jsonSchema
1472
+ });
1473
+ return {};
1474
+ }
1461
1475
  const genericLabels = jsonSchema.getGenericLabels();
1462
1476
  if (!genericLabels) {
1463
1477
  return {};
@@ -26,10 +26,8 @@ function mergeManyOf(kind, schema1, schema2) {
26
26
  const { [kind]: kind1, ...$rest1 } = schema1;
27
27
  const { [kind]: kind2, ...$rest2 } = schema2;
28
28
  let hasRef = false;
29
- const map = [kind1, $rest1, kind2, $rest2]
30
- .flat()
31
- .filter(Boolean)
32
- .reduce((map, schema, index) => {
29
+ const schemas = [kind1, $rest1, kind2, $rest2].flat().filter(Boolean);
30
+ const map = schemas.reduce((map, schema, index) => {
33
31
  schema = cleanObject(schema);
34
32
  if (schema.$ref) {
35
33
  hasRef = true;
@@ -1,2 +1,3 @@
1
+ import { OS3Paths } from "@tsed/openspec";
1
2
  import { JsonSchemaOptions } from "../../interfaces/JsonSchemaOptions.js";
2
- export declare function pathsMapper(model: any, { paths, rootPath, ...options }: JsonSchemaOptions): any;
3
+ export declare function pathsMapper(model: any, { paths, rootPath, ...options }: JsonSchemaOptions): OS3Paths<import("@tsed/openspec").OS3Schema>;
@@ -39,7 +39,7 @@ import { JsonSchema } from "./JsonSchema.js";
39
39
  */
40
40
  export declare class JsonParameter extends JsonMap<OS3Parameter<JsonSchema>> {
41
41
  $kind: string;
42
- expression: string;
42
+ expression: string | undefined;
43
43
  constructor(obj?: Partial<OS3Parameter<JsonSchema>>);
44
44
  getName(): any;
45
45
  name(name: string): this;
@@ -108,9 +108,9 @@ export interface PipeMethods<T = any, R = any> {
108
108
  * @public
109
109
  */
110
110
  export declare class JsonParameterStore extends JsonEntityStore {
111
- paramType: string;
112
- expression: string;
113
- dataPath: string;
111
+ paramType?: string;
112
+ expression?: string;
113
+ dataPath?: string;
114
114
  /**
115
115
  * Define pipes can be called by the framework to transform input parameter
116
116
  */
@@ -24,6 +24,7 @@ export interface JsonSchemaObject extends Omit<JSONSchema7, "type" | "additional
24
24
  additionalProperties?: JsonSchemaObject | boolean | Type | JsonSchema;
25
25
  items?: JsonSchemaObject | boolean | Type | JsonSchema | (JsonSchemaObject | Type | JsonSchema)[];
26
26
  pattern?: string | RegExp;
27
+ [key: `x-${string}`]: unknown;
27
28
  }
28
29
  /**
29
30
  * Union type representing any valid JSON schema representation.
@@ -96,7 +97,7 @@ export declare class JsonSchema<T = JSONSchema7Type> extends Map<string, any> {
96
97
  readonly $isJsonDocument = true;
97
98
  readonly $hooks: Hooks;
98
99
  readonly $allow: any[];
99
- $selfRequired: boolean;
100
+ $selfRequired?: boolean;
100
101
  $ignore: boolean | IgnoreCallback;
101
102
  isDiscriminatorKey: boolean;
102
103
  isDiscriminator: boolean;
@@ -816,6 +817,6 @@ export declare class JsonSchema<T = JSONSchema7Type> extends Map<string, any> {
816
817
  protected setManyOf(keyword: "oneOf" | "anyOf" | "allOf", value: (AnyJsonSchema | null)[]): this | undefined;
817
818
  protected mapToJsonSchema(item: any[]): JsonSchema[];
818
819
  protected mapToJsonSchema(item: any): JsonSchema;
819
- protected mapGenerics(jsonSchema: JsonSchema, generics: GenericValue[][]): GenericsMap;
820
+ protected mapGenerics(jsonSchema: unknown, generics: GenericValue[][]): GenericsMap;
820
821
  protected mapProperties(properties: Record<string, any>): any;
821
822
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@tsed/schema",
3
3
  "description": "JsonSchema module for Ts.ED Framework",
4
4
  "type": "module",
5
- "version": "8.26.0",
5
+ "version": "8.26.2",
6
6
  "source": "./src/index.ts",
7
7
  "main": "./lib/esm/index.js",
8
8
  "module": "./lib/esm/index.js",
@@ -34,7 +34,7 @@
34
34
  "tsed"
35
35
  ],
36
36
  "dependencies": {
37
- "@tsed/openspec": "8.26.0",
37
+ "@tsed/openspec": "8.26.2",
38
38
  "change-case": "^5.4.4",
39
39
  "json-schema": "0.4.0",
40
40
  "picomatch": "4.0.4",
@@ -43,18 +43,18 @@
43
43
  },
44
44
  "devDependencies": {
45
45
  "@apidevtools/swagger-parser": "10.1.0",
46
- "@tsed/barrels": "8.26.0",
47
- "@tsed/core": "8.26.0",
48
- "@tsed/hooks": "8.26.0",
49
- "@tsed/openspec": "8.26.0",
50
- "@tsed/typescript": "8.26.0",
46
+ "@tsed/barrels": "8.26.2",
47
+ "@tsed/core": "8.26.2",
48
+ "@tsed/hooks": "8.26.2",
49
+ "@tsed/openspec": "8.26.2",
50
+ "@tsed/typescript": "8.26.2",
51
51
  "@types/fs-extra": "11.0.4",
52
52
  "@types/json-schema": "7.0.15",
53
53
  "@types/picomatch": "3.0.2",
54
54
  "@types/statuses": "2.0.5",
55
55
  "ajv": "^8.17.1",
56
56
  "eslint": "9.12.0",
57
- "typescript": "5.9.3",
57
+ "typescript": "6.0.2",
58
58
  "vitest": "3.2.4"
59
59
  },
60
60
  "peerDependencies": {