@tsed/schema 8.25.5 → 8.26.1

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
  }
@@ -1,4 +1,4 @@
1
- import { decorateMethodsOf, decoratorTypeOf, DecoratorTypes, isArray, isCollection, isPlainObject, isPrimitiveOrPrimitiveClass, isString } from "@tsed/core";
1
+ import { decorateMethodsOf, decoratorTypeOf, DecoratorTypes, isArray, isClass, isCollection, isPlainObject, isPrimitiveOrPrimitiveClass, isString } from "@tsed/core";
2
2
  import { getStatusMessage } from "../../constants/httpStatusMessages.js";
3
3
  import { DecoratorContext } from "../../domain/DecoratorContext.js";
4
4
  import { JsonEntityStore } from "../../domain/JsonEntityStore.js";
@@ -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
  }
@@ -251,8 +252,8 @@ class ReturnDecoratorContext extends DecoratorContext {
251
252
  }
252
253
  export function Returns(status, model) {
253
254
  const context = new ReturnDecoratorContext({
254
- status,
255
- model
255
+ status: isClass(status) ? 200 : status,
256
+ model: isClass(status) ? status : model
256
257
  });
257
258
  return context.build();
258
259
  }
@@ -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) {
@@ -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>;
@@ -265,4 +265,5 @@ export interface ReturnsChainedDecorators {
265
265
  * @response
266
266
  * @operation
267
267
  */
268
+ export declare function Returns(model?: Type<any> | Type<any>[]): ReturnsChainedDecorators;
268
269
  export declare function Returns(status?: string | number, model?: Type<any> | Type<any>[]): ReturnsChainedDecorators;
@@ -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
  */
@@ -20,6 +20,7 @@ import type { Infer, PropsToShape, SchemaKey, SchemaMerge, SchemaOmit, SchemaPar
20
20
  * @public
21
21
  */
22
22
  export interface JsonSchemaObject extends Omit<JSONSchema7, "type" | "additionalProperties" | "items" | "pattern"> {
23
+ [key: `x-${string}`]: unknown;
23
24
  type?: JSONSchema7["type"] | Type | null | (String | null | Date | Number | Object | Boolean)[];
24
25
  additionalProperties?: JsonSchemaObject | boolean | Type | JsonSchema;
25
26
  items?: JsonSchemaObject | boolean | Type | JsonSchema | (JsonSchemaObject | Type | JsonSchema)[];
@@ -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;
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.25.5",
5
+ "version": "8.26.1",
6
6
  "source": "./src/index.ts",
7
7
  "main": "./lib/esm/index.js",
8
8
  "module": "./lib/esm/index.js",
@@ -34,27 +34,27 @@
34
34
  "tsed"
35
35
  ],
36
36
  "dependencies": {
37
- "@tsed/openspec": "8.25.5",
37
+ "@tsed/openspec": "8.26.1",
38
38
  "change-case": "^5.4.4",
39
39
  "json-schema": "0.4.0",
40
- "picomatch": "4.0.2",
40
+ "picomatch": "4.0.4",
41
41
  "statuses": "^2.0.1",
42
- "tslib": "2.7.0"
42
+ "tslib": ">=2.7.0"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@apidevtools/swagger-parser": "10.1.0",
46
- "@tsed/barrels": "8.25.5",
47
- "@tsed/core": "8.25.5",
48
- "@tsed/hooks": "8.25.5",
49
- "@tsed/openspec": "8.25.5",
50
- "@tsed/typescript": "8.25.5",
46
+ "@tsed/barrels": "8.26.1",
47
+ "@tsed/core": "8.26.1",
48
+ "@tsed/hooks": "8.26.1",
49
+ "@tsed/openspec": "8.26.1",
50
+ "@tsed/typescript": "8.26.1",
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": {