vona-module-a-openapi 5.0.16 → 5.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -519,6 +519,13 @@ function setPublic(target, prop, _descriptor, value) {
519
519
  const options = appMetadata.getOwnMetadataMap(false, SymbolOpenApiOptions, target, prop);
520
520
  options.public = value;
521
521
  }
522
+ function httpCode(httpCode) {
523
+ return function (target, prop, descriptor) {
524
+ const options = appMetadata.getOwnMetadataMap(false, SymbolOpenApiOptions, target, prop);
525
+ options.httpCode = httpCode;
526
+ return descriptor;
527
+ };
528
+ }
522
529
  function contentType(contentType) {
523
530
  return function (target, prop, descriptor) {
524
531
  const options = appMetadata.getOwnMetadataMap(false, SymbolOpenApiOptions, target, prop);
@@ -579,15 +586,29 @@ function headers(headers) {
579
586
  return descriptor;
580
587
  };
581
588
  }
589
+ function setHeader(field, val) {
590
+ return function (target, prop, descriptor) {
591
+ const options = appMetadata.getOwnMetadataMap(false, SymbolOpenApiOptions, target, prop);
592
+ if (!options.setHeaders) options.setHeaders = {};
593
+ if (typeof field === 'string') {
594
+ options.setHeaders[field] = val;
595
+ } else {
596
+ Object.assign(options.setHeaders, field);
597
+ }
598
+ return descriptor;
599
+ };
600
+ }
582
601
  const Api = {
583
602
  field: Field$1,
603
+ httpCode,
584
604
  contentType,
585
605
  body,
586
606
  bodyCustom,
587
607
  exclude,
588
608
  tags,
589
609
  header,
590
- headers
610
+ headers,
611
+ setHeader
591
612
  };
592
613
 
593
614
  function createPipesArgumentDecorator(paramType, extractValue) {
@@ -3,6 +3,7 @@ import type { IOpenApiHeader, TypeResponseContentType } from '../../types/api.ts
3
3
  import type { SchemaLike, SchemaLikeCreate } from '../../types/decorator.ts';
4
4
  import { Field } from './field.ts';
5
5
  export declare function setPublic(target: object, prop?: MetadataKey, _descriptor?: PropertyDescriptor, value?: boolean): void;
6
+ declare function httpCode(httpCode: number): MethodDecorator;
6
7
  declare function contentType(contentType: TypeResponseContentType): MethodDecorator;
7
8
  declare function body(...schemaLikes: SchemaLike[]): MethodDecorator;
8
9
  declare function bodyCustom(bodySchemaWrapper: SchemaLikeCreate | false, ...schemaLikes: SchemaLike[]): MethodDecorator;
@@ -10,8 +11,13 @@ declare function exclude(): ClassDecorator & MethodDecorator;
10
11
  declare function tags(tags: string[]): ClassDecorator & MethodDecorator;
11
12
  declare function header(header: IOpenApiHeader): ClassDecorator & MethodDecorator;
12
13
  declare function headers(headers: IOpenApiHeader[]): ClassDecorator & MethodDecorator;
14
+ declare function setHeader(field: {
15
+ [key: string]: string | string[];
16
+ }): ClassDecorator & MethodDecorator;
17
+ declare function setHeader(field: string, val: string | string[]): ClassDecorator & MethodDecorator;
13
18
  export declare const Api: {
14
19
  field: typeof Field;
20
+ httpCode: typeof httpCode;
15
21
  contentType: typeof contentType;
16
22
  body: typeof body;
17
23
  bodyCustom: typeof bodyCustom;
@@ -19,5 +25,6 @@ export declare const Api: {
19
25
  tags: typeof tags;
20
26
  header: typeof header;
21
27
  headers: typeof headers;
28
+ setHeader: typeof setHeader;
22
29
  };
23
30
  export {};
@@ -8,10 +8,14 @@ export interface IOpenApiHeader {
8
8
  name: string;
9
9
  description?: string;
10
10
  }
11
+ export interface IResponseHeaders {
12
+ [key: string]: string | string[];
13
+ }
11
14
  export interface IOpenApiOptions {
12
15
  public?: boolean;
13
16
  description?: string;
14
17
  summary?: string;
18
+ httpCode?: number;
15
19
  contentType?: TypeResponseContentType;
16
20
  bodySchema?: z.ZodSchema;
17
21
  bodySchemaWrapper?: SchemaLikeCreate | false;
@@ -19,6 +23,7 @@ export interface IOpenApiOptions {
19
23
  tags?: string[];
20
24
  operationId?: string;
21
25
  headers?: IOpenApiHeader[];
26
+ setHeaders?: IResponseHeaders;
22
27
  }
23
28
  export type TypeGenerateJsonScene = 'api' | 'rest';
24
29
  export type TypeOpenApiVersion = 'V30' | 'V31';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vona-module-a-openapi",
3
3
  "type": "module",
4
- "version": "5.0.16",
4
+ "version": "5.0.17",
5
5
  "title": "a-openapi",
6
6
  "vonaModule": {
7
7
  "capabilities": {