@rxap/open-api 13.0.0-next.0 → 13.0.0-next.3

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.
@@ -4,7 +4,7 @@ import * as i1 from '@angular/common/http';
4
4
  import { HttpEventType, HttpClient } from '@angular/common/http';
5
5
  import { __decorate, __metadata } from 'tslib';
6
6
  import * as i2 from '@rxap/open-api';
7
- import { OpenApiConfigService, DEFAULT_OPEN_API_REMOTE_METHOD_META_DATA, RXAP_OPEN_API_STRICT_VALIDATOR, SchemaValidationMixin, RxapOpenApiError } from '@rxap/open-api';
7
+ import { OpenApiConfigService, DEFAULT_OPEN_API_REMOTE_METHOD_META_DATA, RXAP_OPEN_API_STRICT_VALIDATOR, DISABLE_SCHEMA_VALIDATION, DISABLE_VALIDATION, SchemaValidationMixin, RxapOpenApiError } from '@rxap/open-api';
8
8
  import { BaseHttpRemoteMethod } from '@rxap/remote-method/http';
9
9
  import { RxapRemoteMethod } from '@rxap/remote-method';
10
10
  import { joinPath } from '@rxap/utilities';
@@ -18,9 +18,11 @@ function RxapOpenApiRemoteMethod(operationId, serverIndex = 0) {
18
18
  };
19
19
  }
20
20
  let OpenApiRemoteMethod = class OpenApiRemoteMethod extends BaseHttpRemoteMethod {
21
- constructor(http, injector, openApiConfigService, metadata = null, strict = null) {
21
+ constructor(http, injector, openApiConfigService, metadata = null, strict = null, disableSchemaValidation = null, disableValidation = null) {
22
22
  super(http, injector, metadata);
23
23
  this.strict = false;
24
+ this.disableSchemaValidation = false;
25
+ this.disableValidation = false;
24
26
  let operation;
25
27
  if (!this.metadata.operation) {
26
28
  this.metadata.operation = operation = openApiConfigService.getOperation(this.metadata.id);
@@ -36,13 +38,17 @@ let OpenApiRemoteMethod = class OpenApiRemoteMethod extends BaseHttpRemoteMethod
36
38
  ignoreUndefined: this.metadata.ignoreUndefined ?? true,
37
39
  });
38
40
  this.strict = strict || this.metadata.strict || false;
41
+ this.disableSchemaValidation = disableSchemaValidation || this.metadata.disableSchemaValidation || false;
42
+ this.disableValidation = disableValidation || this.metadata.disableValidation || false;
39
43
  }
40
44
  get operation() {
41
45
  return this.metadata.operation;
42
46
  }
43
47
  async _call(args = {}) {
44
- this.validateParameters(this.operation, args.parameters, this.strict);
45
- this.validateRequestBody(this.operation, args.requestBody, this.strict);
48
+ if (!this.disableValidation) {
49
+ this.validateParameters(this.operation, args.parameters, this.strict);
50
+ this.validateRequestBody(this.operation, args.requestBody, this.strict);
51
+ }
46
52
  const response = await this._callWithResponse(args);
47
53
  if (response.body) {
48
54
  return response.body;
@@ -66,25 +72,31 @@ let OpenApiRemoteMethod = class OpenApiRemoteMethod extends BaseHttpRemoteMethod
66
72
  }
67
73
  // TODO : update to the new call method concept (the remove of the _call method concept)
68
74
  _callWithResponse(args = {}) {
69
- this.validateParameters(this.operation, args.parameters, this.strict);
70
- this.validateRequestBody(this.operation, args.requestBody, this.strict);
75
+ if (!this.disableValidation) {
76
+ this.validateParameters(this.operation, args.parameters, this.strict);
77
+ this.validateRequestBody(this.operation, args.requestBody, this.strict);
78
+ }
71
79
  return this.http.request(this.updateRequest(this.buildHttpOptions(this.operation, args.parameters, args.requestBody, this.metadata.ignoreUndefined))).pipe(retry(this.metadata.retry ?? 0), catchError((response) => {
72
80
  this.interceptors?.forEach(interceptor => interceptor
73
81
  .next({ response, parameters: args.parameters, requestBody: args.requestBody }));
74
82
  return throwError(response);
75
- }), filter((event) => event.type === HttpEventType.Response), tap((response) => this.validateResponse(this.operation, response, this.strict)), tap((response) => {
83
+ }), filter((event) => event.type === HttpEventType.Response), tap((response) => {
84
+ if (this.disableValidation) {
85
+ this.validateResponse(this.operation, response, this.strict);
86
+ }
87
+ }), tap((response) => {
76
88
  this.interceptors?.forEach(interceptor => interceptor
77
89
  .next({ response, parameters: args.parameters, requestBody: args.requestBody }));
78
90
  }), take(1), timeout(this.timeout)).toPromise();
79
91
  }
80
92
  };
81
- OpenApiRemoteMethod.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: OpenApiRemoteMethod, deps: [{ token: HttpClient }, { token: Injector }, { token: OpenApiConfigService }, { token: DEFAULT_OPEN_API_REMOTE_METHOD_META_DATA, optional: true }, { token: RXAP_OPEN_API_STRICT_VALIDATOR, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
93
+ OpenApiRemoteMethod.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: OpenApiRemoteMethod, deps: [{ token: HttpClient }, { token: Injector }, { token: OpenApiConfigService }, { token: DEFAULT_OPEN_API_REMOTE_METHOD_META_DATA, optional: true }, { token: RXAP_OPEN_API_STRICT_VALIDATOR, optional: true }, { token: DISABLE_SCHEMA_VALIDATION, optional: true }, { token: DISABLE_VALIDATION, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
82
94
  OpenApiRemoteMethod.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: OpenApiRemoteMethod });
83
95
  OpenApiRemoteMethod = __decorate([
84
96
  Mixin(SchemaValidationMixin),
85
97
  __metadata("design:paramtypes", [HttpClient,
86
98
  Injector,
87
- OpenApiConfigService, Object, Object])
99
+ OpenApiConfigService, Object, Object, Object, Object])
88
100
  ], OpenApiRemoteMethod);
89
101
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: OpenApiRemoteMethod, decorators: [{
90
102
  type: Injectable
@@ -107,6 +119,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImpor
107
119
  }, {
108
120
  type: Inject,
109
121
  args: [RXAP_OPEN_API_STRICT_VALIDATOR]
122
+ }] }, { type: undefined, decorators: [{
123
+ type: Optional
124
+ }, {
125
+ type: Inject,
126
+ args: [DISABLE_SCHEMA_VALIDATION]
127
+ }] }, { type: undefined, decorators: [{
128
+ type: Optional
129
+ }, {
130
+ type: Inject,
131
+ args: [DISABLE_VALIDATION]
110
132
  }] }]; } });
111
133
 
112
134
  class OpenApiRemoteMethodLoader {
@@ -1 +1 @@
1
- {"version":3,"file":"rxap-open-api-remote-method.mjs","sources":["../../../../libs/open-api/remote-method/src/lib/open-api.remote-method.ts","../../../../libs/open-api/remote-method/src/lib/open-api-remote-method.loader.ts","../../../../libs/open-api/remote-method/src/lib/error.ts","../../../../libs/open-api/remote-method/src/rxap-open-api-remote-method.ts"],"sourcesContent":["import {\n Inject,\n Injector,\n Optional,\n Injectable\n} from '@angular/core';\nimport {\n HttpClient,\n HttpResponse,\n HttpEventType,\n HttpErrorResponse\n} from '@angular/common/http';\nimport {\n OperationObjectWithMetadata,\n OpenApiConfigService,\n SchemaValidationMixin,\n RXAP_OPEN_API_STRICT_VALIDATOR,\n DEFAULT_OPEN_API_REMOTE_METHOD_META_DATA\n} from '@rxap/open-api';\nimport { BaseHttpRemoteMethod } from '@rxap/remote-method/http';\nimport {\n BaseRemoteMethodMetadata,\n RxapRemoteMethod\n} from '@rxap/remote-method';\nimport { joinPath } from '@rxap/utilities';\nimport {\n filter,\n timeout,\n retry,\n catchError,\n tap,\n take\n} from 'rxjs/operators';\nimport { throwError } from 'rxjs';\nimport { Mixin } from '@rxap/mixin';\n\nexport function RxapOpenApiRemoteMethod(operationId: string, serverIndex: number = 0) {\n return function(target: any) {\n RxapRemoteMethod({ id: operationId, serverIndex })(target);\n };\n}\n\nexport interface OpenApiRemoteMethodMetadata extends BaseRemoteMethodMetadata {\n /**\n * The operation object with path and method\n */\n operation?: OperationObjectWithMetadata;\n /**\n * The index of the server object in the servers array in the open api config\n */\n serverIndex?: number;\n id: string;\n}\n\nexport interface OpenApiRemoteMethodParameter<Parameters extends Record<string, any> | void = any, RequestBody = any> {\n parameters?: Parameters,\n requestBody?: RequestBody\n}\n\nexport interface OpenApiRemoteMethod<Response = any, Parameters extends Record<string, any> | void = any, RequestBody = any>\n extends SchemaValidationMixin<Response, Parameters, RequestBody> {}\n\n@Mixin(SchemaValidationMixin)\n@Injectable()\nexport class OpenApiRemoteMethod<Response = any, Parameters extends Record<string, any> | void = any, RequestBody = any>\n extends BaseHttpRemoteMethod<Response, any, OpenApiRemoteMethodParameter<Parameters, RequestBody>> {\n\n public get operation(): OperationObjectWithMetadata {\n return this.metadata.operation;\n }\n\n private readonly strict: boolean = false;\n\n constructor(\n @Inject(HttpClient) http: HttpClient,\n @Inject(Injector) injector: Injector,\n @Inject(OpenApiConfigService) openApiConfigService: OpenApiConfigService,\n @Optional()\n @Inject(DEFAULT_OPEN_API_REMOTE_METHOD_META_DATA)\n metadata: OpenApiRemoteMethodMetadata | null = null,\n @Optional()\n @Inject(RXAP_OPEN_API_STRICT_VALIDATOR)\n strict: boolean | null = null\n ) {\n super(http, injector, metadata);\n let operation: OperationObjectWithMetadata;\n if (!this.metadata.operation) {\n this.metadata.operation = operation = openApiConfigService.getOperation(this.metadata.id);\n } else {\n operation = this.metadata.operation;\n }\n this.applyMetadata({\n id: operation.operationId,\n url: () => joinPath(openApiConfigService.getBaseUrl(this.metadata.serverIndex), operation.path),\n method: operation.method as any,\n withCredentials: this.metadata.withCredentials ?? true,\n ignoreUndefined: this.metadata.ignoreUndefined ?? true,\n });\n this.strict = strict || this.metadata.strict || false;\n }\n\n protected async _call(args: OpenApiRemoteMethodParameter<Parameters, RequestBody> = {}): Promise<Response> {\n\n this.validateParameters(this.operation, args.parameters, this.strict);\n this.validateRequestBody(this.operation, args.requestBody, this.strict);\n\n const response = await this._callWithResponse(args);\n\n if (response.body) {\n return response.body;\n }\n\n console.warn('The response body is empty!');\n return null as any;\n }\n\n /**\n * Instead of returning the response body the full response object is returned\n */\n public async callWithResponse(args: OpenApiRemoteMethodParameter<Parameters, RequestBody> = {}): Promise<HttpResponse<Response>> {\n this.init();\n this.executionsInProgress$.increase();\n const result = await this._callWithResponse(args);\n this.executionsInProgress$.decrease();\n if (result.body) {\n this.executed$.next(result.body);\n this.executed(result.body);\n }\n return result;\n }\n\n // TODO : update to the new call method concept (the remove of the _call method concept)\n public _callWithResponse(args: OpenApiRemoteMethodParameter<Parameters, RequestBody> = {}): Promise<HttpResponse<Response>> {\n\n this.validateParameters(this.operation, args.parameters, this.strict);\n this.validateRequestBody(this.operation, args.requestBody, this.strict);\n\n return this.http.request<Response>(this.updateRequest(this.buildHttpOptions(this.operation, args.parameters, args.requestBody, this.metadata.ignoreUndefined))).pipe(\n retry(this.metadata.retry ?? 0),\n catchError((response: HttpErrorResponse) => {\n this.interceptors?.forEach(interceptor => interceptor\n .next({ response, parameters: args.parameters, requestBody: args.requestBody })\n );\n return throwError(response);\n }),\n filter((event: any) => event.type === HttpEventType.Response),\n tap((response: HttpResponse<Response>) => this.validateResponse(this.operation, response, this.strict)),\n tap((response: HttpResponse<Response>) => {\n this.interceptors?.forEach(interceptor => interceptor\n .next({ response, parameters: args.parameters, requestBody: args.requestBody })\n );\n }),\n take(1),\n timeout(this.timeout)\n ).toPromise();\n\n }\n\n}\n","import {\n Injectable,\n Injector,\n Inject\n} from '@angular/core';\nimport { HttpClient } from '@angular/common/http';\nimport { OpenApiRemoteMethod } from './open-api.remote-method';\nimport { OpenApiConfigService } from '@rxap/open-api';\n\n@Injectable({ providedIn: 'root' })\nexport class OpenApiRemoteMethodLoader {\n\n constructor(\n @Inject(OpenApiConfigService) public readonly openApiConfig: OpenApiConfigService,\n @Inject(HttpClient) public readonly http: HttpClient,\n public readonly injector: Injector\n ) {}\n\n public load(definitionId: string): OpenApiRemoteMethod | null {\n const operation = this.openApiConfig.getOperation(definitionId);\n\n if (operation) {\n\n return new OpenApiRemoteMethod(\n this.http,\n this.injector,\n this.openApiConfig,\n {\n id: definitionId,\n operation\n }\n );\n\n }\n\n return null;\n\n }\n\n}\n","import { RxapOpenApiError } from '@rxap/open-api';\n\nexport class RxapOpenApiRemoteMethodError extends RxapOpenApiError {\n\n constructor(message: string, code?: string, scope?: string) {\n super(message, code, scope);\n this.addSubPackageName('remote-method');\n }\n\n}\n","/**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CAAC;QAC5B,IAAI,CAAC,iBAAiB,CAAC,eAAe,CAAC,CAAC;KACzC;;;ACPH;;;;;;"}
1
+ {"version":3,"file":"rxap-open-api-remote-method.mjs","sources":["../../../../libs/open-api/remote-method/src/lib/open-api.remote-method.ts","../../../../libs/open-api/remote-method/src/lib/open-api-remote-method.loader.ts","../../../../libs/open-api/remote-method/src/lib/error.ts","../../../../libs/open-api/remote-method/src/rxap-open-api-remote-method.ts"],"sourcesContent":["import {\n Inject,\n Injector,\n Optional,\n Injectable\n} from '@angular/core';\nimport {\n HttpClient,\n HttpResponse,\n HttpEventType,\n HttpErrorResponse\n} from '@angular/common/http';\nimport {\n OperationObjectWithMetadata,\n OpenApiConfigService,\n SchemaValidationMixin,\n RXAP_OPEN_API_STRICT_VALIDATOR,\n DEFAULT_OPEN_API_REMOTE_METHOD_META_DATA,\n DISABLE_SCHEMA_VALIDATION,\n DISABLE_VALIDATION\n} from '@rxap/open-api';\nimport { BaseHttpRemoteMethod } from '@rxap/remote-method/http';\nimport {\n BaseRemoteMethodMetadata,\n RxapRemoteMethod\n} from '@rxap/remote-method';\nimport { joinPath } from '@rxap/utilities';\nimport {\n filter,\n timeout,\n retry,\n catchError,\n tap,\n take\n} from 'rxjs/operators';\nimport { throwError } from 'rxjs';\nimport { Mixin } from '@rxap/mixin';\n\nexport function RxapOpenApiRemoteMethod(operationId: string, serverIndex: number = 0) {\n return function(target: any) {\n RxapRemoteMethod({ id: operationId, serverIndex })(target);\n };\n}\n\nexport interface OpenApiRemoteMethodMetadata extends BaseRemoteMethodMetadata {\n /**\n * The operation object with path and method\n */\n operation?: OperationObjectWithMetadata;\n /**\n * The index of the server object in the servers array in the open api config\n */\n serverIndex?: number;\n id: string;\n}\n\nexport interface OpenApiRemoteMethodParameter<Parameters extends Record<string, any> | void = any, RequestBody = any> {\n parameters?: Parameters,\n requestBody?: RequestBody\n}\n\nexport interface OpenApiRemoteMethod<Response = any, Parameters extends Record<string, any> | void = any, RequestBody = any>\n extends SchemaValidationMixin<Response, Parameters, RequestBody> {}\n\n@Mixin(SchemaValidationMixin)\n@Injectable()\nexport class OpenApiRemoteMethod<Response = any, Parameters extends Record<string, any> | void = any, RequestBody = any>\n extends BaseHttpRemoteMethod<Response, any, OpenApiRemoteMethodParameter<Parameters, RequestBody>> {\n\n public get operation(): OperationObjectWithMetadata {\n return this.metadata.operation;\n }\n\n private readonly strict: boolean = false;\n protected readonly disableSchemaValidation: boolean = false;\n protected readonly disableValidation: boolean = false;\n\n constructor(\n @Inject(HttpClient) http: HttpClient,\n @Inject(Injector) injector: Injector,\n @Inject(OpenApiConfigService) openApiConfigService: OpenApiConfigService,\n @Optional()\n @Inject(DEFAULT_OPEN_API_REMOTE_METHOD_META_DATA)\n metadata: OpenApiRemoteMethodMetadata | null = null,\n @Optional()\n @Inject(RXAP_OPEN_API_STRICT_VALIDATOR)\n strict: boolean | null = null,\n @Optional()\n @Inject(DISABLE_SCHEMA_VALIDATION)\n disableSchemaValidation: boolean | null = null,\n @Optional()\n @Inject(DISABLE_VALIDATION)\n disableValidation: boolean | null = null\n ) {\n super(http, injector, metadata);\n let operation: OperationObjectWithMetadata;\n if (!this.metadata.operation) {\n this.metadata.operation = operation = openApiConfigService.getOperation(this.metadata.id);\n } else {\n operation = this.metadata.operation;\n }\n this.applyMetadata({\n id: operation.operationId,\n url: () => joinPath(openApiConfigService.getBaseUrl(this.metadata.serverIndex), operation.path),\n method: operation.method as any,\n withCredentials: this.metadata.withCredentials ?? true,\n ignoreUndefined: this.metadata.ignoreUndefined ?? true,\n });\n this.strict = strict || this.metadata.strict || false;\n this.disableSchemaValidation = disableSchemaValidation || this.metadata.disableSchemaValidation || false;\n this.disableValidation = disableValidation || this.metadata.disableValidation || false;\n }\n\n protected async _call(args: OpenApiRemoteMethodParameter<Parameters, RequestBody> = {}): Promise<Response> {\n\n if (!this.disableValidation) {\n this.validateParameters(this.operation, args.parameters, this.strict);\n this.validateRequestBody(this.operation, args.requestBody, this.strict);\n }\n\n const response = await this._callWithResponse(args);\n\n if (response.body) {\n return response.body;\n }\n\n console.warn('The response body is empty!');\n return null as any;\n }\n\n /**\n * Instead of returning the response body the full response object is returned\n */\n public async callWithResponse(args: OpenApiRemoteMethodParameter<Parameters, RequestBody> = {}): Promise<HttpResponse<Response>> {\n this.init();\n this.executionsInProgress$.increase();\n const result = await this._callWithResponse(args);\n this.executionsInProgress$.decrease();\n if (result.body) {\n this.executed$.next(result.body);\n this.executed(result.body);\n }\n return result;\n }\n\n // TODO : update to the new call method concept (the remove of the _call method concept)\n public _callWithResponse(args: OpenApiRemoteMethodParameter<Parameters, RequestBody> = {}): Promise<HttpResponse<Response>> {\n\n if (!this.disableValidation) {\n this.validateParameters(this.operation, args.parameters, this.strict);\n this.validateRequestBody(this.operation, args.requestBody, this.strict);\n }\n\n return this.http.request<Response>(this.updateRequest(this.buildHttpOptions(this.operation, args.parameters, args.requestBody, this.metadata.ignoreUndefined))).pipe(\n retry(this.metadata.retry ?? 0),\n catchError((response: HttpErrorResponse) => {\n this.interceptors?.forEach(interceptor => interceptor\n .next({ response, parameters: args.parameters, requestBody: args.requestBody })\n );\n return throwError(response);\n }),\n filter((event: any) => event.type === HttpEventType.Response),\n tap((response: HttpResponse<Response>) => {\n if (this.disableValidation) {\n this.validateResponse(this.operation, response, this.strict);\n }\n }),\n tap((response: HttpResponse<Response>) => {\n this.interceptors?.forEach(interceptor => interceptor\n .next({ response, parameters: args.parameters, requestBody: args.requestBody })\n );\n }),\n take(1),\n timeout(this.timeout)\n ).toPromise();\n\n }\n\n}\n","import {\n Injectable,\n Injector,\n Inject\n} from '@angular/core';\nimport { HttpClient } from '@angular/common/http';\nimport { OpenApiRemoteMethod } from './open-api.remote-method';\nimport { OpenApiConfigService } from '@rxap/open-api';\n\n@Injectable({ providedIn: 'root' })\nexport class OpenApiRemoteMethodLoader {\n\n constructor(\n @Inject(OpenApiConfigService) public readonly openApiConfig: OpenApiConfigService,\n @Inject(HttpClient) public readonly http: HttpClient,\n public readonly injector: Injector\n ) {}\n\n public load(definitionId: string): OpenApiRemoteMethod | null {\n const operation = this.openApiConfig.getOperation(definitionId);\n\n if (operation) {\n\n return new OpenApiRemoteMethod(\n this.http,\n this.injector,\n this.openApiConfig,\n {\n id: definitionId,\n operation\n }\n );\n\n }\n\n return null;\n\n }\n\n}\n","import { RxapOpenApiError } from '@rxap/open-api';\n\nexport class RxapOpenApiRemoteMethodError extends RxapOpenApiError {\n\n constructor(message: string, code?: string, scope?: string) {\n super(message, code, scope);\n this.addSubPackageName('remote-method');\n }\n\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;;;;;;;;;;;SAsCgB,uBAAuB,CAAC,WAAmB,EAAE,cAAsB,CAAC;IAClF,OAAO,UAAS,MAAW;QACzB,gBAAgB,CAAC,EAAE,EAAE,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;KAC5D,CAAC;AACJ,CAAC;IAwBY,mBAAmB,SAAnB,mBACX,SAAQ,oBAA0F;IAUlG,YACsB,IAAgB,EAClB,QAAkB,EACN,oBAA0C,EAGtE,WAA+C,IAAI,EAGnD,SAA2D,IAAI,EAGjE,0BAA0C,IAAI,EAG5C,oBAAoC,IAAI;QAE1C,KAAK,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;QArBjB,WAAM,GAAY,KAAK,CAAC;QACtB,4BAAuB,GAAY,KAAK,CAAC;QACzC,sBAAiB,GAAY,KAAK,CAAC;QAoBpD,IAAI,SAAsC,CAAC;QAC3C,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE;YAC5B,IAAI,CAAC,QAAQ,CAAC,SAAS,GAAG,SAAS,GAAG,oBAAoB,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;SAC3F;aAAM;YACL,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC;SAC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BACR,MAAM;2BAAC,8BAA8B;;0BAErC,QAAQ;;0BACR,MAAM;2BAAC,yBAAyB;;0BAEhC,QAAQ;;0BACR,MAAM;2BAAC,kBAAkB;;;MCjFjB,yBAAyB;IAEpC,YACgD,aAAmC,EAC7C,IAAgB,EACpC,QAAkB;QAFY,kBAAa,GAAb,aAAa,CAAsB;QAC7C,SAAI,GAAJ,IAAI,CAAY;QACpC,aAAQ,GAAR,QAAQ,CAAU;KAChC;IAEG,IAAI,CAAC,YAAoB;QAC9B,MAAM,SAAS,GAAG,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;QAEhE,IAAI,SAAS,EAAE;YAEb,OAAO,IAAI,mBAAmB,CAC5B,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,aAAa,EAClB;gBACE,EAAE,EAAE,YAAY;gBAChB,SAAS;aACV,CACF,CAAC;SAEH;QAED,OAAO,IAAI,CAAC;KAEb;;sHA3BU,yBAAyB,kBAG1B,oBAAoB,aACpB,UAAU;0HAJT,yBAAyB,cADZ,MAAM;2FACnB,yBAAyB;kBADrC,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;0BAI7B,MAAM;2BAAC,oBAAoB;;0BAC3B,MAAM;2BAAC,UAAU;;;MCZT,4BAA6B,SAAQ,gBAAgB;IAEhE,YAAY,OAAe,EAAE,IAAa,EAAE,KAAc;QACxD,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;QAC5B,IAAI,CAAC,iBAAiB,CAAC,eAAe,CAAC,CAAC;KACzC;;;ACPH;;;;;;"}
@@ -1,6 +1,6 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { InjectionToken, Injectable, Optional, Inject, isDevMode } from '@angular/core';
3
- import { RxapError, coerceArray, IsRecord, isPromiseLike } from '@rxap/utilities';
3
+ import { RxapError, coerceArray, IsRecord, clone, isPromiseLike } from '@rxap/utilities';
4
4
  import * as Ajv from 'ajv-oai';
5
5
  import { HttpParams, HttpHeaders } from '@angular/common/http';
6
6
 
@@ -8,6 +8,8 @@ const RXAP_OPEN_API_CONFIG = new InjectionToken('rxap/open-api/config');
8
8
  const RXAP_OPEN_API_STRICT_VALIDATOR = new InjectionToken('rxap/open-api/strict-validator');
9
9
  const DEFAULT_OPEN_API_REMOTE_METHOD_META_DATA = new InjectionToken('rxap/open-api/default-remote-method-meta-data');
10
10
  const DEFAULT_OPEN_API_DATA_SOURCE_META_DATA = new InjectionToken('rxap/open-api/default-data-source-meta-data');
11
+ const DISABLE_SCHEMA_VALIDATION = new InjectionToken('rxap/open-api/disable-schema-validation');
12
+ const DISABLE_VALIDATION = new InjectionToken('rxap/open-api/disable-validation');
11
13
 
12
14
  class RxapOpenApiError extends RxapError {
13
15
  constructor(message, code, scope) {
@@ -385,9 +387,12 @@ class SchemaValidationMixin {
385
387
  return options;
386
388
  }
387
389
  validate(schema, value) {
390
+ if (this.disableSchemaValidation) {
391
+ return true;
392
+ }
388
393
  let result;
389
394
  try {
390
- result = new Ajv().validate(schema, value);
395
+ result = new Ajv().validate(schema, clone(value));
391
396
  }
392
397
  catch (e) {
393
398
  console.error(e.message);
@@ -405,5 +410,5 @@ SchemaValidationMixin.STRICT = false;
405
410
  * Generated bundle index. Do not edit.
406
411
  */
407
412
 
408
- export { AssertOpenApiV3, DEFAULT_OPEN_API_DATA_SOURCE_META_DATA, DEFAULT_OPEN_API_REMOTE_METHOD_META_DATA, IsOpenApiV3, IsReferenceObject, NotContainsReferenceObjects, OpenApiConfigService, RXAP_OPEN_API_CONFIG, RXAP_OPEN_API_STRICT_VALIDATOR, RxapOpenApiError, SchemaValidationMixin };
413
+ export { AssertOpenApiV3, DEFAULT_OPEN_API_DATA_SOURCE_META_DATA, DEFAULT_OPEN_API_REMOTE_METHOD_META_DATA, DISABLE_SCHEMA_VALIDATION, DISABLE_VALIDATION, IsOpenApiV3, IsReferenceObject, NotContainsReferenceObjects, OpenApiConfigService, RXAP_OPEN_API_CONFIG, RXAP_OPEN_API_STRICT_VALIDATOR, RxapOpenApiError, SchemaValidationMixin };
409
414
  //# sourceMappingURL=rxap-open-api.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"rxap-open-api.mjs","sources":["../../../../libs/open-api/src/lib/tokens.ts","../../../../libs/open-api/src/lib/error.ts","../../../../libs/open-api/src/lib/utilities.ts","../../../../libs/open-api/src/lib/open-api-config.service.ts","../../../../libs/open-api/src/lib/schema-validation.mixin.ts","../../../../libs/open-api/src/rxap-open-api.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\n\nexport const RXAP_OPEN_API_CONFIG = new InjectionToken('rxap/open-api/config');\nexport const RXAP_OPEN_API_STRICT_VALIDATOR = new InjectionToken('rxap/open-api/strict-validator');\nexport const DEFAULT_OPEN_API_REMOTE_METHOD_META_DATA = new InjectionToken('rxap/open-api/default-remote-method-meta-data');\nexport const DEFAULT_OPEN_API_DATA_SOURCE_META_DATA = new InjectionToken('rxap/open-api/default-data-source-meta-data');\n","import { RxapError } from '@rxap/utilities';\n\nexport class RxapOpenApiError extends RxapError {\n\n constructor(message: string, code?: string, scope?: string) {\n super('@rxap/open-api', message, code ?? '', scope);\n }\n\n}\n","import { OpenAPIV3 } from 'openapi-types';\nimport { RxapOpenApiError } from './error';\n\nexport function IsReferenceObject(obj?: any): obj is OpenAPIV3.ReferenceObject {\n return !!obj && obj.hasOwnProperty('$ref');\n}\n\nexport function NotContainsReferenceObjects<T>(array?: Array<OpenAPIV3.ReferenceObject | T | undefined>): array is T[] {\n return !!array && array.every(item => !IsReferenceObject(item) && !!item);\n}\n\nexport function IsOpenApiV3(obj?: any): obj is OpenAPIV3.Document {\n return !!obj && obj.hasOwnProperty('openapi') && obj.openapi.match(/^3\\./);\n}\n\nexport function AssertOpenApiV3(obj?: any): asserts obj is OpenAPIV3.Document {\n\n if (!IsOpenApiV3(obj)) {\n throw new RxapOpenApiError('Only openapi version 3.x.x is supported');\n }\n\n}\n","import {\n Injectable,\n Inject,\n Optional\n} from '@angular/core';\nimport { OperationObjectWithMetadata } from './open-api';\nimport { RXAP_OPEN_API_CONFIG } from './tokens';\nimport {\n OpenAPIV3,\n OpenAPI\n} from 'openapi-types';\nimport { AssertOpenApiV3 } from './utilities';\n\nexport type OperationMap = Map<string, OperationObjectWithMetadata>;\n\n@Injectable({ providedIn: 'root' })\nexport class OpenApiConfigService {\n public static Config: OpenAPIV3.Document | null = null;\n\n public static DefaultServerIndex: number = 0;\n\n private static _operations: OperationMap | null = null;\n\n /**\n * Used to load the app open api config from a remote resource.\n *\n * Promise.all([ OpenApiDataSourceLoader.Load() ])\n * .then(() => platformBrowserDynamic().bootstrapModule(AppModule))\n * .catch(err => console.error(err))\n *\n */\n public static async Load(openApiUrl: string = 'openapi.json'): Promise<void> {\n if (!openApiUrl) {\n throw new Error('The open api url is not defined!');\n }\n\n let config: OpenAPIV3.Document | null = null;\n try {\n const response = await fetch(openApiUrl);\n config = await response.json();\n } catch (error: any) {\n console.debug(\n `Could not load the open api config from '${openApiUrl}'!`,\n error\n );\n console.error(\n `Could not load the open api config from '${openApiUrl}'!`,\n error.message\n );\n }\n\n if (config) {\n const expandedConfig = await this.ExpandOpenApi(config);\n\n AssertOpenApiV3(expandedConfig);\n\n this.Config = expandedConfig;\n } else {\n this.Config = null;\n }\n }\n\n public static GetOperation(operationId: string): OperationObjectWithMetadata {\n if (!this.Config) {\n throw new Error('Could not load open api config');\n }\n\n if (!this._operations) {\n this._operations = this.LoadOperations(this.Config);\n }\n if (!this._operations!.has(operationId)) {\n throw new Error(\n `The operation '${operationId}' is not defined in the openapi-json`\n );\n }\n return this._operations!.get(operationId)!;\n }\n\n private static LoadOperations(config: OpenAPIV3.Document): OperationMap {\n const operations = new Map<string, OperationObjectWithMetadata>();\n\n Object.entries(config.paths)\n .filter(\n (item): item is [string, OpenAPIV3.PathItemObject] =>\n item[0] !== undefined\n )\n .filter(\n ([_, methods]: [string, OpenAPIV3.PathItemObject]) =>\n methods &&\n Object.keys(methods).some((method) =>\n ['get', 'put', 'post', 'delete', 'patch'].includes(method)\n )\n )\n .forEach(([path, methods]: [string, OpenAPIV3.PathItemObject]) =>\n Object.entries(methods)\n .filter(\n (item): item is [string, OpenAPIV3.OperationObject] =>\n item[0] !== undefined\n )\n .forEach(\n ([method, operation]: [string, OpenAPIV3.OperationObject]) => {\n if (!operation.operationId) {\n throw new Error('The OpenApu OperationId is not defined');\n }\n\n if (operations!.has(operation.operationId)) {\n throw new Error(\n `The OpenApi Operation '${operation.operationId}' is already defined.`\n );\n }\n\n operations!.set(operation.operationId, {\n ...operation,\n path: path,\n method: method.toUpperCase(),\n });\n }\n )\n );\n\n return operations;\n }\n\n private static GetBaseUrl(\n config: OpenAPIV3.Document,\n serverIndex: number = this.DefaultServerIndex\n ): string {\n const server = config.servers ? config.servers[serverIndex] : null;\n\n if (!server) {\n console.debug(\n `Could not extract the server config with the index '${serverIndex}' from the open api config`,\n config\n );\n throw new Error(\n `Could not extract the server config with the index '${serverIndex}' from the open api config`\n );\n }\n\n return server.url;\n }\n\n /**\n * Replaces all $ref with the concrete definition\n *\n * @param config\n * @private\n */\n private static ExpandOpenApi(\n config: OpenAPI.Document\n ): Promise<OpenAPI.Document> {\n return Promise.resolve(config);\n }\n\n public readonly config: OpenAPIV3.Document;\n\n public defaultServerIndex: number = OpenApiConfigService.DefaultServerIndex;\n\n private readonly _operations: OperationMap;\n\n constructor(\n @Optional()\n @Inject(RXAP_OPEN_API_CONFIG)\n config: OpenAPIV3.Document | null = null\n ) {\n config = config ?? OpenApiConfigService.Config;\n if (!config) {\n throw new Error('Could not load open api config');\n }\n this.config = config;\n this._operations = OpenApiConfigService.LoadOperations(config);\n }\n\n public getOperation(operationId: string): OperationObjectWithMetadata {\n if (!this._operations!.has(operationId)) {\n console.debug(\n `The operation '${operationId}' is not defined in the openapi-json`,\n this.config\n );\n throw new Error(\n `The operation '${operationId}' is not defined in the openapi-json`\n );\n }\n return this._operations!.get(operationId)!;\n }\n\n public getBaseUrl(serverIndex: number = this.defaultServerIndex): string {\n return OpenApiConfigService.GetBaseUrl(this.config, serverIndex);\n }\n\n public insertServer(\n serverConfig: OpenAPIV3.ServerObject,\n index: number = this.defaultServerIndex\n ): void {\n if (!this.config.servers) {\n this.config.servers = [];\n }\n this.config.servers.splice(index, 1, serverConfig);\n }\n}\n","import {\n coerceArray,\n isPromiseLike,\n IsRecord\n} from '@rxap/utilities';\nimport { isDevMode } from '@angular/core';\nimport * as Ajv from 'ajv-oai';\nimport {\n HttpParams,\n HttpHeaders\n} from '@angular/common/http';\nimport {\n NotContainsReferenceObjects,\n IsReferenceObject\n} from './utilities';\nimport { OperationObjectWithMetadata } from './open-api';\nimport { RxapOpenApiError } from './error';\nimport { OpenAPIV3 } from 'openapi-types';\nimport { HttpRemoteMethodParameter } from '@rxap/remote-method/http';\n\nexport interface SchemaValidationResponse<Data> {\n headers: Record<string, any>;\n status: number;\n body?: Data | null;\n data?: Data;\n}\n\nexport class SchemaValidationMixin<Response = any, Parameters extends Record<string, any> | void = any, RequestBody = any> {\n\n public static STRICT: boolean = false;\n\n /**\n * Validates the parameters against the schema specified in the operation object\n *\n * @param operation\n * @param parameters\n * @param strict\n * @protected\n */\n public validateParameters(operation: OperationObjectWithMetadata, parameters?: Parameters, strict: boolean = false): void {\n\n const operationParameters = coerceArray(operation.parameters);\n\n if (!NotContainsReferenceObjects<OpenAPIV3.ParameterObject>(operationParameters)) {\n throw new RxapOpenApiError('The operation parameters contains ReferenceObject!');\n }\n\n if (parameters === undefined) {\n // TODO : find concept to definition witch parameter should not be checked if required\n // header parameters are never required if changes the semantic release manager breaks\n const requiredParameters = operationParameters.filter(parameter => parameter.required && parameter.in !== 'header');\n if (requiredParameters.length) {\n if (isDevMode()) {\n console.debug('Some operation parameters are required!', requiredParameters.map(p => p.name));\n }\n this.validationError('Some operation parameters are required!', strict);\n }\n\n } else if (IsRecord(parameters)) {\n\n for (const parameter of operationParameters) {\n\n if (parameter.required) {\n // header parameters are never required if changes the semantic release manager breaks\n if (parameter.in !== 'header') {\n if (!parameters.hasOwnProperty(parameter.name)) {\n this.validationError(`The operation parameter '${parameter.name}' is required!`, strict);\n }\n }\n }\n\n\n if (parameter.schema) {\n if (parameters.hasOwnProperty(parameter.name)) {\n\n const value = parameters[ parameter.name ];\n\n if (!this.validate(parameter.schema, value)) {\n this.validationError(`The parameter '${parameter.name}' is not valid against the schema!`, strict, parameter.schema, value);\n }\n\n }\n }\n\n }\n\n } else {\n if (operationParameters.length === 0 || operationParameters.every(op => !op.required)) {\n if (isDevMode()) {\n console.warn(`The operation ${operation.operationId} does not expect any parameters. But a parameter is provided.`, parameters);\n }\n } else {\n throw new Error('The parameters object is not a record');\n }\n }\n\n }\n\n /**\n * Validates the http response against the schema specified in the operation object\n *\n * @param operation\n * @param response\n * @param strict\n * @protected\n */\n public validateResponse(operation: OperationObjectWithMetadata, response: SchemaValidationResponse<Response>, strict: boolean = false): void {\n\n // region only validate the response if the content type is undefined or application/json\n\n const contentType = response.headers.get('Content-Type');\n\n if (contentType && contentType !== 'application/json') {\n if (isDevMode()) {\n console.warn('Response validation is only supported for content type application/json');\n }\n return;\n }\n\n // endregion\n\n if (operation.responses) {\n\n const status = response.status;\n\n // region extract the response object based on the response status\n let responseObject: OpenAPIV3.ResponseObject | OpenAPIV3.ReferenceObject | undefined;\n\n if (operation.responses[status]) {\n responseObject = operation.responses[status];\n } else {\n // use the default response object if no matching was found.\n responseObject = operation.responses.default;\n }\n // endregion\n\n if (responseObject) {\n\n if (IsReferenceObject(responseObject)) {\n throw new RxapOpenApiError('Found a reference object. The operation config is not expand!');\n }\n\n // region validate the response against the schema if defined\n\n // TODO : create schema that validates all parameters at once\n\n if (responseObject.content && responseObject.content['application/json'] && responseObject.content['application/json'].schema) {\n\n const schema = responseObject.content['application/json'].schema;\n\n const data = response.body ?? response.data;\n\n if (!this.validate(schema, data)) {\n this.validationError('The response is not valid ageist the operation schema!', strict, schema, data);\n }\n\n }\n\n // endregion\n\n }\n\n\n }\n\n }\n\n public validateRequestBody(operation: OperationObjectWithMetadata, body?: RequestBody, strict: boolean = false): void {\n\n // only validate body if type of object\n if (typeof body !== 'object') {\n return;\n }\n\n if (operation.requestBody) {\n\n if (IsReferenceObject(operation.requestBody)) {\n throw new RxapOpenApiError('Found a reference object. The operation config is not expand!');\n }\n\n if (body === undefined && operation.requestBody.required) {\n this.validationError('The request body is required!', strict);\n }\n\n if (operation.requestBody.content && operation.requestBody.content['application/json']) {\n\n const schema = operation.requestBody.content['application/json'].schema;\n\n if (schema) {\n if (!this.validate(schema, body)) {\n this.validationError('The request body is not valid!', strict, schema, body);\n }\n }\n\n }\n\n }\n\n }\n\n public validationError(message: string, strict: boolean, schema?: OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject, value?: any) {\n if (isDevMode() && schema !== undefined) {\n // tslint:disable-next-line:no-console\n console.debug(message, { schema, value });\n }\n if (strict || SchemaValidationMixin.STRICT) {\n throw new RxapOpenApiError(message, '', 'SchemaValidationMixin');\n } else {\n console.warn(message);\n }\n }\n\n public buildHttpParams(operationParameters: OpenAPIV3.ParameterObject[], parameters?: Parameters, ignoreUndefined = true): HttpParams {\n\n let params = new HttpParams();\n\n if (IsRecord(parameters)) {\n\n for (const parameter of operationParameters.filter(p => p.in === 'query')) {\n const parameterName = parameter.name;\n\n if (parameters.hasOwnProperty(parameter.name)) {\n\n const value = parameters[ parameter.name ];\n\n if (value === undefined && ignoreUndefined) {\n continue;\n }\n\n if (Array.isArray(value)) {\n\n if (value.length) {\n\n const first = value.shift();\n\n params = params.set(parameterName, first);\n\n for (const item of value) {\n params = params.append(parameterName, item);\n }\n\n }\n\n } else {\n params = params.set(parameter.name, value);\n }\n\n }\n\n }\n\n }\n\n return params;\n\n }\n\n public buildHttpHeaders(operationParameters: OpenAPIV3.ParameterObject[], parameters?: Parameters): HttpHeaders {\n\n let headers = new HttpHeaders();\n\n if (IsRecord(parameters)) {\n\n for (const parameter of operationParameters.filter(p => p.in === 'header')) {\n\n if (parameters.hasOwnProperty(parameter.name)) {\n\n const value = parameters[ parameter.name ];\n\n if (Array.isArray(value)) {\n\n if (value.length) {\n\n const first = value.shift();\n\n headers = headers.set(parameters.name, first);\n\n for (const item of value) {\n headers = headers.append(parameters.name, item);\n }\n\n }\n\n } else {\n headers = headers.set(parameter.name, value);\n }\n\n }\n\n }\n\n }\n\n return headers;\n\n }\n\n public buildHttpPathParams(operationParameters: OpenAPIV3.ParameterObject[], parameters?: Parameters): Record<string, string> {\n\n const pathParams: Record<string, any> = {};\n\n if (IsRecord(parameters)) {\n\n for (const parameter of operationParameters.filter(p => p.in === 'path')) {\n\n if (parameters.hasOwnProperty(parameter.name)) {\n pathParams[ parameter.name ] = encodeURIComponent(parameters[ parameter.name ]);\n }\n\n }\n\n }\n\n return pathParams;\n\n }\n\n /**\n * Converts open api parameters into the corresponding http options to\n * create a http request. The transformation is guided by the openapi definition\n *\n * @param operation\n * @param parameters\n * @param requestBody\n * @param ignoreUndefined\n */\n public buildHttpOptions(operation: OperationObjectWithMetadata, parameters?: Parameters, requestBody?: RequestBody, ignoreUndefined = true): HttpRemoteMethodParameter {\n\n const options: HttpRemoteMethodParameter = {};\n\n const operationParameters = coerceArray(operation.parameters);\n\n if (!NotContainsReferenceObjects<OpenAPIV3.ParameterObject>(operationParameters)) {\n throw new RxapOpenApiError('The operation parameters contains ReferenceObject!');\n }\n\n const params = this.buildHttpParams(operationParameters, parameters, ignoreUndefined);\n const headers = this.buildHttpHeaders(operationParameters, parameters);\n const pathParams: Record<string, any> = this.buildHttpPathParams(operationParameters, parameters);\n\n if (params.keys().length) {\n options.params = params;\n }\n\n if (headers.keys().length) {\n options.headers = headers;\n }\n\n if (Object.keys(pathParams).length) {\n options.pathParams = pathParams;\n }\n\n if (requestBody !== undefined) {\n options.body = requestBody;\n }\n\n return options;\n\n }\n\n private validate(schema: string | boolean | object, value: any): boolean {\n\n let result: boolean | PromiseLike<any>;\n\n try {\n result = new Ajv().validate(schema, value);\n } catch (e: any) {\n console.error(e.message);\n return false;\n }\n\n if (isPromiseLike(result)) {\n throw new Error('Async schema validation is not yet supported. Ensure the all refs in the openapi schema are internal!');\n }\n\n return result;\n }\n\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;MAEa,oBAAoB,GAAuB,IAAI,cAAc,CAAC,sBAAsB,EAAE;MACtF,8BAA8B,GAAa,IAAI,cAAc,CAAC,gCAAgC,EAAE;MAChG,wCAAwC,GAAG,IAAI,cAAc,CAAC,+CAA+C,EAAE;MAC/G,sCAAsC,GAAK,IAAI,cAAc,CAAC,6CAA6C;;MCH3G,gBAAiB,SAAQ,SAAS;IAE7C,YAAY,OAAe,EAAE,IAAa,EAAE,KAAc;QACxD,KAAK,CAAC,gBAAgB,EAAE,OAAO,EAAE,IAAI,IAAI,EAAE,EAAE,KAAK,CAAC,CAAC;KACrD;;;SCHa,iBAAiB,CAAC,GAAS;IACzC,OAAO,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;AAC7C,CAAC;SAEe,2BAA2B,CAAI,KAAwD;IACrG,OAAO,CAAC,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;AAC5E,CAAC;SAEe,WAAW,CAAC,GAAS;IACnC,OAAO,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AAC7E,CAAC;SAEe,eAAe,CAAC,GAAS;IAEvC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE;QACrB,MAAM,IAAI,gBAAgB,CAAC,yCAAyC,CAAC,CAAC;KACvE;AAEH;;MCLa,oBAAoB;IAgJ/B,YAGE,SAAoC,IAAI;QAP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QAED,OAAO,MAAM,CAAC;KACf;;AA3Va,4BAAM,GAAY,KAAK;;AC7BvC;;;;;;"}
1
+ {"version":3,"file":"rxap-open-api.mjs","sources":["../../../../libs/open-api/src/lib/tokens.ts","../../../../libs/open-api/src/lib/error.ts","../../../../libs/open-api/src/lib/utilities.ts","../../../../libs/open-api/src/lib/open-api-config.service.ts","../../../../libs/open-api/src/lib/schema-validation.mixin.ts","../../../../libs/open-api/src/rxap-open-api.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\n\nexport const RXAP_OPEN_API_CONFIG = new InjectionToken('rxap/open-api/config');\nexport const RXAP_OPEN_API_STRICT_VALIDATOR = new InjectionToken('rxap/open-api/strict-validator');\nexport const DEFAULT_OPEN_API_REMOTE_METHOD_META_DATA = new InjectionToken('rxap/open-api/default-remote-method-meta-data');\nexport const DEFAULT_OPEN_API_DATA_SOURCE_META_DATA = new InjectionToken('rxap/open-api/default-data-source-meta-data');\nexport const DISABLE_SCHEMA_VALIDATION = new InjectionToken<boolean>('rxap/open-api/disable-schema-validation');\nexport const DISABLE_VALIDATION = new InjectionToken<boolean>('rxap/open-api/disable-validation');\n","import { RxapError } from '@rxap/utilities';\n\nexport class RxapOpenApiError extends RxapError {\n\n constructor(message: string, code?: string, scope?: string) {\n super('@rxap/open-api', message, code ?? '', scope);\n }\n\n}\n","import { OpenAPIV3 } from 'openapi-types';\nimport { RxapOpenApiError } from './error';\n\nexport function IsReferenceObject(obj?: any): obj is OpenAPIV3.ReferenceObject {\n return !!obj && obj.hasOwnProperty('$ref');\n}\n\nexport function NotContainsReferenceObjects<T>(array?: Array<OpenAPIV3.ReferenceObject | T | undefined>): array is T[] {\n return !!array && array.every(item => !IsReferenceObject(item) && !!item);\n}\n\nexport function IsOpenApiV3(obj?: any): obj is OpenAPIV3.Document {\n return !!obj && obj.hasOwnProperty('openapi') && obj.openapi.match(/^3\\./);\n}\n\nexport function AssertOpenApiV3(obj?: any): asserts obj is OpenAPIV3.Document {\n\n if (!IsOpenApiV3(obj)) {\n throw new RxapOpenApiError('Only openapi version 3.x.x is supported');\n }\n\n}\n","import {\n Injectable,\n Inject,\n Optional\n} from '@angular/core';\nimport { OperationObjectWithMetadata } from './open-api';\nimport { RXAP_OPEN_API_CONFIG } from './tokens';\nimport {\n OpenAPIV3,\n OpenAPI\n} from 'openapi-types';\nimport { AssertOpenApiV3 } from './utilities';\n\nexport type OperationMap = Map<string, OperationObjectWithMetadata>;\n\n@Injectable({ providedIn: 'root' })\nexport class OpenApiConfigService {\n public static Config: OpenAPIV3.Document | null = null;\n\n public static DefaultServerIndex: number = 0;\n\n private static _operations: OperationMap | null = null;\n\n /**\n * Used to load the app open api config from a remote resource.\n *\n * Promise.all([ OpenApiDataSourceLoader.Load() ])\n * .then(() => platformBrowserDynamic().bootstrapModule(AppModule))\n * .catch(err => console.error(err))\n *\n */\n public static async Load(openApiUrl: string = 'openapi.json'): Promise<void> {\n if (!openApiUrl) {\n throw new Error('The open api url is not defined!');\n }\n\n let config: OpenAPIV3.Document | null = null;\n try {\n const response = await fetch(openApiUrl);\n config = await response.json();\n } catch (error: any) {\n console.debug(\n `Could not load the open api config from '${openApiUrl}'!`,\n error\n );\n console.error(\n `Could not load the open api config from '${openApiUrl}'!`,\n error.message\n );\n }\n\n if (config) {\n const expandedConfig = await this.ExpandOpenApi(config);\n\n AssertOpenApiV3(expandedConfig);\n\n this.Config = expandedConfig;\n } else {\n this.Config = null;\n }\n }\n\n public static GetOperation(operationId: string): OperationObjectWithMetadata {\n if (!this.Config) {\n throw new Error('Could not load open api config');\n }\n\n if (!this._operations) {\n this._operations = this.LoadOperations(this.Config);\n }\n if (!this._operations!.has(operationId)) {\n throw new Error(\n `The operation '${operationId}' is not defined in the openapi-json`\n );\n }\n return this._operations!.get(operationId)!;\n }\n\n private static LoadOperations(config: OpenAPIV3.Document): OperationMap {\n const operations = new Map<string, OperationObjectWithMetadata>();\n\n Object.entries(config.paths)\n .filter(\n (item): item is [string, OpenAPIV3.PathItemObject] =>\n item[0] !== undefined\n )\n .filter(\n ([_, methods]: [string, OpenAPIV3.PathItemObject]) =>\n methods &&\n Object.keys(methods).some((method) =>\n ['get', 'put', 'post', 'delete', 'patch'].includes(method)\n )\n )\n .forEach(([path, methods]: [string, OpenAPIV3.PathItemObject]) =>\n Object.entries(methods)\n .filter(\n (item): item is [string, OpenAPIV3.OperationObject] =>\n item[0] !== undefined\n )\n .forEach(\n ([method, operation]: [string, OpenAPIV3.OperationObject]) => {\n if (!operation.operationId) {\n throw new Error('The OpenApu OperationId is not defined');\n }\n\n if (operations!.has(operation.operationId)) {\n throw new Error(\n `The OpenApi Operation '${operation.operationId}' is already defined.`\n );\n }\n\n operations!.set(operation.operationId, {\n ...operation,\n path: path,\n method: method.toUpperCase(),\n });\n }\n )\n );\n\n return operations;\n }\n\n private static GetBaseUrl(\n config: OpenAPIV3.Document,\n serverIndex: number = this.DefaultServerIndex\n ): string {\n const server = config.servers ? config.servers[serverIndex] : null;\n\n if (!server) {\n console.debug(\n `Could not extract the server config with the index '${serverIndex}' from the open api config`,\n config\n );\n throw new Error(\n `Could not extract the server config with the index '${serverIndex}' from the open api config`\n );\n }\n\n return server.url;\n }\n\n /**\n * Replaces all $ref with the concrete definition\n *\n * @param config\n * @private\n */\n private static ExpandOpenApi(\n config: OpenAPI.Document\n ): Promise<OpenAPI.Document> {\n return Promise.resolve(config);\n }\n\n public readonly config: OpenAPIV3.Document;\n\n public defaultServerIndex: number = OpenApiConfigService.DefaultServerIndex;\n\n private readonly _operations: OperationMap;\n\n constructor(\n @Optional()\n @Inject(RXAP_OPEN_API_CONFIG)\n config: OpenAPIV3.Document | null = null\n ) {\n config = config ?? OpenApiConfigService.Config;\n if (!config) {\n throw new Error('Could not load open api config');\n }\n this.config = config;\n this._operations = OpenApiConfigService.LoadOperations(config);\n }\n\n public getOperation(operationId: string): OperationObjectWithMetadata {\n if (!this._operations!.has(operationId)) {\n console.debug(\n `The operation '${operationId}' is not defined in the openapi-json`,\n this.config\n );\n throw new Error(\n `The operation '${operationId}' is not defined in the openapi-json`\n );\n }\n return this._operations!.get(operationId)!;\n }\n\n public getBaseUrl(serverIndex: number = this.defaultServerIndex): string {\n return OpenApiConfigService.GetBaseUrl(this.config, serverIndex);\n }\n\n public insertServer(\n serverConfig: OpenAPIV3.ServerObject,\n index: number = this.defaultServerIndex\n ): void {\n if (!this.config.servers) {\n this.config.servers = [];\n }\n this.config.servers.splice(index, 1, serverConfig);\n }\n}\n","import {\n coerceArray,\n isPromiseLike,\n IsRecord,\n clone\n} from '@rxap/utilities';\nimport { isDevMode } from '@angular/core';\nimport * as Ajv from 'ajv-oai';\nimport {\n HttpParams,\n HttpHeaders\n} from '@angular/common/http';\nimport {\n NotContainsReferenceObjects,\n IsReferenceObject\n} from './utilities';\nimport { OperationObjectWithMetadata } from './open-api';\nimport { RxapOpenApiError } from './error';\nimport { OpenAPIV3 } from 'openapi-types';\nimport { HttpRemoteMethodParameter } from '@rxap/remote-method/http';\n\nexport interface SchemaValidationResponse<Data> {\n headers: Record<string, any>;\n status: number;\n body?: Data | null;\n data?: Data;\n}\n\nexport class SchemaValidationMixin<Response = any, Parameters extends Record<string, any> | void = any, RequestBody = any> {\n\n public static STRICT: boolean = false;\n\n protected disableSchemaValidation?: boolean\n\n /**\n * Validates the parameters against the schema specified in the operation object\n *\n * @param operation\n * @param parameters\n * @param strict\n * @protected\n */\n public validateParameters(operation: OperationObjectWithMetadata, parameters?: Parameters, strict: boolean = false): void {\n\n const operationParameters = coerceArray(operation.parameters);\n\n if (!NotContainsReferenceObjects<OpenAPIV3.ParameterObject>(operationParameters)) {\n throw new RxapOpenApiError('The operation parameters contains ReferenceObject!');\n }\n\n if (parameters === undefined) {\n // TODO : find concept to definition witch parameter should not be checked if required\n // header parameters are never required if changes the semantic release manager breaks\n const requiredParameters = operationParameters.filter(parameter => parameter.required && parameter.in !== 'header');\n if (requiredParameters.length) {\n if (isDevMode()) {\n console.debug('Some operation parameters are required!', requiredParameters.map(p => p.name));\n }\n this.validationError('Some operation parameters are required!', strict);\n }\n\n } else if (IsRecord(parameters)) {\n\n for (const parameter of operationParameters) {\n\n if (parameter.required) {\n // header parameters are never required if changes the semantic release manager breaks\n if (parameter.in !== 'header') {\n if (!parameters.hasOwnProperty(parameter.name)) {\n this.validationError(`The operation parameter '${parameter.name}' is required!`, strict);\n }\n }\n }\n\n\n if (parameter.schema) {\n if (parameters.hasOwnProperty(parameter.name)) {\n\n const value = parameters[ parameter.name ];\n\n if (!this.validate(parameter.schema, value)) {\n this.validationError(`The parameter '${parameter.name}' is not valid against the schema!`, strict, parameter.schema, value);\n }\n\n }\n }\n\n }\n\n } else {\n if (operationParameters.length === 0 || operationParameters.every(op => !op.required)) {\n if (isDevMode()) {\n console.warn(`The operation ${operation.operationId} does not expect any parameters. But a parameter is provided.`, parameters);\n }\n } else {\n throw new Error('The parameters object is not a record');\n }\n }\n\n }\n\n /**\n * Validates the http response against the schema specified in the operation object\n *\n * @param operation\n * @param response\n * @param strict\n * @protected\n */\n public validateResponse(operation: OperationObjectWithMetadata, response: SchemaValidationResponse<Response>, strict: boolean = false): void {\n\n // region only validate the response if the content type is undefined or application/json\n\n const contentType = response.headers.get('Content-Type');\n\n if (contentType && contentType !== 'application/json') {\n if (isDevMode()) {\n console.warn('Response validation is only supported for content type application/json');\n }\n return;\n }\n\n // endregion\n\n if (operation.responses) {\n\n const status = response.status;\n\n // region extract the response object based on the response status\n let responseObject: OpenAPIV3.ResponseObject | OpenAPIV3.ReferenceObject | undefined;\n\n if (operation.responses[status]) {\n responseObject = operation.responses[status];\n } else {\n // use the default response object if no matching was found.\n responseObject = operation.responses.default;\n }\n // endregion\n\n if (responseObject) {\n\n if (IsReferenceObject(responseObject)) {\n throw new RxapOpenApiError('Found a reference object. The operation config is not expand!');\n }\n\n // region validate the response against the schema if defined\n\n // TODO : create schema that validates all parameters at once\n\n if (responseObject.content && responseObject.content['application/json'] && responseObject.content['application/json'].schema) {\n\n const schema = responseObject.content['application/json'].schema;\n\n const data = response.body ?? response.data;\n\n if (!this.validate(schema, data)) {\n this.validationError('The response is not valid ageist the operation schema!', strict, schema, data);\n }\n\n }\n\n // endregion\n\n }\n\n\n }\n\n }\n\n public validateRequestBody(operation: OperationObjectWithMetadata, body?: RequestBody, strict: boolean = false): void {\n\n // only validate body if type of object\n if (typeof body !== 'object') {\n return;\n }\n\n if (operation.requestBody) {\n\n if (IsReferenceObject(operation.requestBody)) {\n throw new RxapOpenApiError('Found a reference object. The operation config is not expand!');\n }\n\n if (body === undefined && operation.requestBody.required) {\n this.validationError('The request body is required!', strict);\n }\n\n if (operation.requestBody.content && operation.requestBody.content['application/json']) {\n\n const schema = operation.requestBody.content['application/json'].schema;\n\n if (schema) {\n if (!this.validate(schema, body)) {\n this.validationError('The request body is not valid!', strict, schema, body);\n }\n }\n\n }\n\n }\n\n }\n\n public validationError(message: string, strict: boolean, schema?: OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject, value?: any) {\n if (isDevMode() && schema !== undefined) {\n // tslint:disable-next-line:no-console\n console.debug(message, { schema, value });\n }\n if (strict || SchemaValidationMixin.STRICT) {\n throw new RxapOpenApiError(message, '', 'SchemaValidationMixin');\n } else {\n console.warn(message);\n }\n }\n\n public buildHttpParams(operationParameters: OpenAPIV3.ParameterObject[], parameters?: Parameters, ignoreUndefined = true): HttpParams {\n\n let params = new HttpParams();\n\n if (IsRecord(parameters)) {\n\n for (const parameter of operationParameters.filter(p => p.in === 'query')) {\n const parameterName = parameter.name;\n\n if (parameters.hasOwnProperty(parameter.name)) {\n\n const value = parameters[ parameter.name ];\n\n if (value === undefined && ignoreUndefined) {\n continue;\n }\n\n if (Array.isArray(value)) {\n\n if (value.length) {\n\n const first = value.shift();\n\n params = params.set(parameterName, first);\n\n for (const item of value) {\n params = params.append(parameterName, item);\n }\n\n }\n\n } else {\n params = params.set(parameter.name, value);\n }\n\n }\n\n }\n\n }\n\n return params;\n\n }\n\n public buildHttpHeaders(operationParameters: OpenAPIV3.ParameterObject[], parameters?: Parameters): HttpHeaders {\n\n let headers = new HttpHeaders();\n\n if (IsRecord(parameters)) {\n\n for (const parameter of operationParameters.filter(p => p.in === 'header')) {\n\n if (parameters.hasOwnProperty(parameter.name)) {\n\n const value = parameters[ parameter.name ];\n\n if (Array.isArray(value)) {\n\n if (value.length) {\n\n const first = value.shift();\n\n headers = headers.set(parameters.name, first);\n\n for (const item of value) {\n headers = headers.append(parameters.name, item);\n }\n\n }\n\n } else {\n headers = headers.set(parameter.name, value);\n }\n\n }\n\n }\n\n }\n\n return headers;\n\n }\n\n public buildHttpPathParams(operationParameters: OpenAPIV3.ParameterObject[], parameters?: Parameters): Record<string, string> {\n\n const pathParams: Record<string, any> = {};\n\n if (IsRecord(parameters)) {\n\n for (const parameter of operationParameters.filter(p => p.in === 'path')) {\n\n if (parameters.hasOwnProperty(parameter.name)) {\n pathParams[ parameter.name ] = encodeURIComponent(parameters[ parameter.name ]);\n }\n\n }\n\n }\n\n return pathParams;\n\n }\n\n /**\n * Converts open api parameters into the corresponding http options to\n * create a http request. The transformation is guided by the openapi definition\n *\n * @param operation\n * @param parameters\n * @param requestBody\n * @param ignoreUndefined\n */\n public buildHttpOptions(operation: OperationObjectWithMetadata, parameters?: Parameters, requestBody?: RequestBody, ignoreUndefined = true): HttpRemoteMethodParameter {\n\n const options: HttpRemoteMethodParameter = {};\n\n const operationParameters = coerceArray(operation.parameters);\n\n if (!NotContainsReferenceObjects<OpenAPIV3.ParameterObject>(operationParameters)) {\n throw new RxapOpenApiError('The operation parameters contains ReferenceObject!');\n }\n\n const params = this.buildHttpParams(operationParameters, parameters, ignoreUndefined);\n const headers = this.buildHttpHeaders(operationParameters, parameters);\n const pathParams: Record<string, any> = this.buildHttpPathParams(operationParameters, parameters);\n\n if (params.keys().length) {\n options.params = params;\n }\n\n if (headers.keys().length) {\n options.headers = headers;\n }\n\n if (Object.keys(pathParams).length) {\n options.pathParams = pathParams;\n }\n\n if (requestBody !== undefined) {\n options.body = requestBody;\n }\n\n return options;\n\n }\n\n private validate(schema: string | boolean | object, value: any): boolean {\n\n if (this.disableSchemaValidation) {\n return true;\n }\n\n let result: boolean | PromiseLike<any>;\n\n try {\n result = new Ajv().validate(schema, clone(value));\n } catch (e: any) {\n console.error(e.message);\n return false;\n }\n\n if (isPromiseLike(result)) {\n throw new Error('Async schema validation is not yet supported. Ensure the all refs in the openapi schema are internal!');\n }\n\n return result;\n }\n\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;MAEa,oBAAoB,GAAuB,IAAI,cAAc,CAAC,sBAAsB,EAAE;MACtF,8BAA8B,GAAa,IAAI,cAAc,CAAC,gCAAgC,EAAE;MAChG,wCAAwC,GAAG,IAAI,cAAc,CAAC,+CAA+C,EAAE;MAC/G,sCAAsC,GAAK,IAAI,cAAc,CAAC,6CAA6C,EAAE;MAC7G,yBAAyB,GAAkB,IAAI,cAAc,CAAU,yCAAyC,EAAE;MAClH,kBAAkB,GAAkB,IAAI,cAAc,CAAU,kCAAkC;;MCLlG,gBAAiB,SAAQ,SAAS;IAE7C,YAAY,OAAe,EAAE,IAAa,EAAE,KAAc;QACxD,KAAK,CAAC,gBAAgB,EAAE,OAAO,EAAE,IAAI,IAAI,EAAE,EAAE,KAAK,CAAC,CAAC;KACrD;;;SCHa,iBAAiB,CAAC,GAAS;IACzC,OAAO,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;AAC7C,CAAC;SAEe,2BAA2B,CAAI,KAAwD;IACrG,OAAO,CAAC,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;AAC5E,CAAC;SAEe,WAAW,CAAC,GAAS;IACnC,OAAO,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,GAAG,CAAC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IAAI;YACF,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;SACnD;QAAC,OAAO,CAAM,EAAE;YACf,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;YACzB,OAAO,KAAK,CAAC;SACd;QAED,IAAI,aAAa,CAAC,MAAM,CAAC,EAAE;YACzB,MAAM,IAAI,KAAK,CAAC,uGAAuG,CAAC,CAAC;SAC1H;QAED,OAAO,MAAM,CAAC;KACf;;AAjWa,4BAAM,GAAY,KAAK;;AC9BvC;;;;;;"}
@@ -10,6 +10,7 @@ export interface SchemaValidationResponse<Data> {
10
10
  }
11
11
  export declare class SchemaValidationMixin<Response = any, Parameters extends Record<string, any> | void = any, RequestBody = any> {
12
12
  static STRICT: boolean;
13
+ protected disableSchemaValidation?: boolean;
13
14
  /**
14
15
  * Validates the parameters against the schema specified in the operation object
15
16
  *
package/lib/tokens.d.ts CHANGED
@@ -3,3 +3,5 @@ export declare const RXAP_OPEN_API_CONFIG: InjectionToken<unknown>;
3
3
  export declare const RXAP_OPEN_API_STRICT_VALIDATOR: InjectionToken<unknown>;
4
4
  export declare const DEFAULT_OPEN_API_REMOTE_METHOD_META_DATA: InjectionToken<unknown>;
5
5
  export declare const DEFAULT_OPEN_API_DATA_SOURCE_META_DATA: InjectionToken<unknown>;
6
+ export declare const DISABLE_SCHEMA_VALIDATION: InjectionToken<boolean>;
7
+ export declare const DISABLE_VALIDATION: InjectionToken<boolean>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rxap/open-api",
3
- "version": "13.0.0-next.0",
3
+ "version": "13.0.0-next.3",
4
4
  "private": false,
5
5
  "author": "Merzough Münker",
6
6
  "homepage": "https://gitlab.com/rxap/packages/libs/open-api",
@@ -24,19 +24,19 @@
24
24
  "@angular/core": "^13.2.3",
25
25
  "@angular/platform-browser": "^13.2.3",
26
26
  "@angular/platform-browser-dynamic": "^13.2.3",
27
- "@rxap/data-source": "^13.0.0-next.0",
28
- "@rxap/definition": "^13.0.0-next.0",
29
- "@rxap/mixin": "^13.0.0-next.0",
30
- "@rxap/remote-method": "^13.0.0-next.0",
31
- "@rxap/utilities": "^13.0.0-next.0",
27
+ "@rxap/data-source": "^13.0.0-next.3",
28
+ "@rxap/definition": "^13.0.0-next.2",
29
+ "@rxap/mixin": "^13.0.0-next.1",
30
+ "@rxap/remote-method": "^13.0.0-next.1",
31
+ "@rxap/utilities": "^13.0.0-next.2",
32
32
  "@schematics/angular": "^13.2.4",
33
33
  "reflect-metadata": "^0.1.13",
34
34
  "rxjs": "^6.5.5"
35
35
  },
36
36
  "dependencies": {
37
- "@rxap/schematics-open-api": "^13.0.0-next.0",
38
- "@rxap/schematics-ts-morph": "^13.0.0-next.0",
39
- "@rxap/schematics-utilities": "^13.0.0-next.0",
37
+ "@rxap/schematics-open-api": "^13.0.0-next.1",
38
+ "@rxap/schematics-ts-morph": "^13.0.0-next.1",
39
+ "@rxap/schematics-utilities": "^13.0.0-next.1",
40
40
  "ajv-oai": "^1.2.1",
41
41
  "openapi-types": "^10.0.0",
42
42
  "ts-morph": "^13.0.3",
@@ -25,13 +25,15 @@ export interface OpenApiRemoteMethod<Response = any, Parameters extends Record<s
25
25
  export declare class OpenApiRemoteMethod<Response = any, Parameters extends Record<string, any> | void = any, RequestBody = any> extends BaseHttpRemoteMethod<Response, any, OpenApiRemoteMethodParameter<Parameters, RequestBody>> {
26
26
  get operation(): OperationObjectWithMetadata;
27
27
  private readonly strict;
28
- constructor(http: HttpClient, injector: Injector, openApiConfigService: OpenApiConfigService, metadata?: OpenApiRemoteMethodMetadata | null, strict?: boolean | null);
28
+ protected readonly disableSchemaValidation: boolean;
29
+ protected readonly disableValidation: boolean;
30
+ constructor(http: HttpClient, injector: Injector, openApiConfigService: OpenApiConfigService, metadata?: OpenApiRemoteMethodMetadata | null, strict?: boolean | null, disableSchemaValidation?: boolean | null, disableValidation?: boolean | null);
29
31
  protected _call(args?: OpenApiRemoteMethodParameter<Parameters, RequestBody>): Promise<Response>;
30
32
  /**
31
33
  * Instead of returning the response body the full response object is returned
32
34
  */
33
35
  callWithResponse(args?: OpenApiRemoteMethodParameter<Parameters, RequestBody>): Promise<HttpResponse<Response>>;
34
36
  _callWithResponse(args?: OpenApiRemoteMethodParameter<Parameters, RequestBody>): Promise<HttpResponse<Response>>;
35
- static ɵfac: i0.ɵɵFactoryDeclaration<OpenApiRemoteMethod<any, any, any>, [null, null, null, { optional: true; }, { optional: true; }]>;
37
+ static ɵfac: i0.ɵɵFactoryDeclaration<OpenApiRemoteMethod<any, any, any>, [null, null, null, { optional: true; }, { optional: true; }, { optional: true; }, { optional: true; }]>;
36
38
  static ɵprov: i0.ɵɵInjectableDeclaration<OpenApiRemoteMethod<any, any, any>>;
37
39
  }