Loading src/app/openApis/geographicSiteManagement/api-configuration.ts +179 −164 Original line number Diff line number Diff line import { HttpParameterCodec } from '@angular/common/http'; import { Param } from './param'; import { Injectable, Inject } from '@angular/core'; export interface ConfigurationParameters { /** * @deprecated Since 5.0. Use credentials instead */ apiKeys?: {[ key: string ]: string}; username?: string; password?: string; /** * @deprecated Since 5.0. Use credentials instead */ accessToken?: string | (() => string); basePath?: string; withCredentials?: boolean; /** * Takes care of encoding query- and form-parameters. */ encoder?: HttpParameterCodec; /** * Override the default method for encoding path parameters in various * <a href="https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#style-values">styles</a>. * <p> * See {@link README.md} for more details * </p> */ encodeParam?: (param: Param) => string; /** * The keys are the names in the securitySchemes section of the OpenAPI * document. They should map to the value used for authentication * minus any standard prefixes such as 'Basic' or 'Bearer'. */ credentials?: {[ key: string ]: string | (() => string | undefined)}; } export class Configuration { /** * @deprecated Since 5.0. Use credentials instead */ apiKeys?: {[ key: string ]: string}; username?: string; password?: string; /** * @deprecated Since 5.0. Use credentials instead */ accessToken?: string | (() => string); basePath?: string; withCredentials?: boolean; /** * Takes care of encoding query- and form-parameters. */ encoder?: HttpParameterCodec; /** * Encoding of various path parameter * <a href="https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#style-values">styles</a>. * <p> * See {@link README.md} for more details * </p> */ encodeParam: (param: Param) => string; /** * The keys are the names in the securitySchemes section of the OpenAPI * document. They should map to the value used for authentication * minus any standard prefixes such as 'Basic' or 'Bearer'. */ credentials: {[ key: string ]: string | (() => string | undefined)}; constructor(configurationParameters: ConfigurationParameters = {}) { this.apiKeys = configurationParameters.apiKeys; this.username = configurationParameters.username; this.password = configurationParameters.password; this.accessToken = configurationParameters.accessToken; this.basePath = configurationParameters.basePath; this.withCredentials = configurationParameters.withCredentials; this.encoder = configurationParameters.encoder; if (configurationParameters.encodeParam) { this.encodeParam = configurationParameters.encodeParam; } else { this.encodeParam = param => this.defaultEncodeParam(param); } if (configurationParameters.credentials) { this.credentials = configurationParameters.credentials; } else { this.credentials = {}; } } /** * Select the correct content-type to use for a request. * Uses {@link Configuration#isJsonMime} to determine the correct content-type. * If no content type is found return the first found type if the contentTypes is not empty * @param contentTypes - the array of content types that are available for selection * @returns the selected content-type or <code>undefined</code> if no selection could be made. */ public selectHeaderContentType (contentTypes: string[]): string | undefined { if (contentTypes.length === 0) { return undefined; } const type = contentTypes.find((x: string) => this.isJsonMime(x)); if (type === undefined) { return contentTypes[0]; } return type; } /** * Select the correct accept content-type to use for a request. * Uses {@link Configuration#isJsonMime} to determine the correct accept content-type. * If no content type is found return the first found type if the contentTypes is not empty * @param accepts - the array of content types that are available for selection. * @returns the selected content-type or <code>undefined</code> if no selection could be made. */ public selectHeaderAccept(accepts: string[]): string | undefined { if (accepts.length === 0) { return undefined; } const type = accepts.find((x: string) => this.isJsonMime(x)); if (type === undefined) { return accepts[0]; } return type; } /** * Check if the given MIME is a JSON MIME. * JSON MIME examples: * application/json * application/json; charset=UTF8 * APPLICATION/JSON * application/vnd.company+json * @param mime - MIME (Multipurpose Internet Mail Extensions) * @return True if the given MIME is JSON, false otherwise. */ public isJsonMime(mime: string): boolean { const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i'); return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json'); } public lookupCredential(key: string): string | undefined { const value = this.credentials[key]; return typeof value === 'function' ? value() : value; } private defaultEncodeParam(param: Param): string { // This implementation exists as fallback for missing configuration // and for backwards compatibility to older typescript-angular generator versions. // It only works for the 'simple' parameter style. // Date-handling only works for the 'date-time' format. // All other styles and Date-formats are probably handled incorrectly. // export interface ConfigurationParameters { // /** // * @deprecated Since 5.0. Use credentials instead // */ // apiKeys?: {[ key: string ]: string}; // username?: string; // password?: string; // /** // * @deprecated Since 5.0. Use credentials instead // */ // accessToken?: string | (() => string); // basePath?: string; // withCredentials?: boolean; // /** // * Takes care of encoding query- and form-parameters. // */ // encoder?: HttpParameterCodec; // /** // * Override the default method for encoding path parameters in various // * <a href="https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#style-values">styles</a>. // * <p> // * See {@link README.md} for more details // * </p> // */ // encodeParam?: (param: Param) => string; // /** // * The keys are the names in the securitySchemes section of the OpenAPI // * document. They should map to the value used for authentication // * minus any standard prefixes such as 'Basic' or 'Bearer'. // */ // credentials?: {[ key: string ]: string | (() => string | undefined)}; // } // // But: if that's all you need (i.e.: the most common use-case): no need for customization! const value = param.dataFormat === 'date-time' && param.value instanceof Date ? (param.value as Date).toISOString() : param.value; return encodeURIComponent(String(value)); } // @Injectable({ // providedIn: 'root', // }) // export class ApiConfiguration { // /** // * @deprecated Since 5.0. Use credentials instead // */ // apiKeys?: {[ key: string ]: string}; // username?: string; // password?: string; // /** // * @deprecated Since 5.0. Use credentials instead // */ // accessToken?: string | (() => string); // basePath?: string; // withCredentials?: boolean; // /** // * Takes care of encoding query- and form-parameters. // */ // encoder?: HttpParameterCodec; // /** // * Encoding of various path parameter // * <a href="https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#style-values">styles</a>. // * <p> // * See {@link README.md} for more details // * </p> // */ // encodeParam: (param: Param) => string; // /** // * The keys are the names in the securitySchemes section of the OpenAPI // * document. They should map to the value used for authentication // * minus any standard prefixes such as 'Basic' or 'Bearer'. // */ // credentials: {[ key: string ]: string | (() => string | undefined)}; // // constructor(configurationParameters: ConfigurationParameters = {}) { // this.apiKeys = configurationParameters.apiKeys; // this.username = configurationParameters.username; // this.password = configurationParameters.password; // this.accessToken = configurationParameters.accessToken; // this.basePath = configurationParameters.basePath; // this.withCredentials = configurationParameters.withCredentials; // this.encoder = configurationParameters.encoder; // if (configurationParameters.encodeParam) { // this.encodeParam = configurationParameters.encodeParam; // } // else { // this.encodeParam = param => this.defaultEncodeParam(param); // } // if (configurationParameters.credentials) { // this.credentials = configurationParameters.credentials; // } // else { // this.credentials = {}; // } // } // // /** // * Select the correct content-type to use for a request. // * Uses {@link Configuration#isJsonMime} to determine the correct content-type. // * If no content type is found return the first found type if the contentTypes is not empty // * @param contentTypes - the array of content types that are available for selection // * @returns the selected content-type or <code>undefined</code> if no selection could be made. // */ // public selectHeaderContentType (contentTypes: string[]): string | undefined { // if (contentTypes.length === 0) { // return undefined; // } // // const type = contentTypes.find((x: string) => this.isJsonMime(x)); // if (type === undefined) { // return contentTypes[0]; // } // return type; // } // // /** // * Select the correct accept content-type to use for a request. // * Uses {@link Configuration#isJsonMime} to determine the correct accept content-type. // * If no content type is found return the first found type if the contentTypes is not empty // * @param accepts - the array of content types that are available for selection. // * @returns the selected content-type or <code>undefined</code> if no selection could be made. // */ // public selectHeaderAccept(accepts: string[]): string | undefined { // if (accepts.length === 0) { // return undefined; // } // // const type = accepts.find((x: string) => this.isJsonMime(x)); // if (type === undefined) { // return accepts[0]; // } // return type; // } // // /** // * Check if the given MIME is a JSON MIME. // * JSON MIME examples: // * application/json // * application/json; charset=UTF8 // * APPLICATION/JSON // * application/vnd.company+json // * @param mime - MIME (Multipurpose Internet Mail Extensions) // * @return True if the given MIME is JSON, false otherwise. // */ // public isJsonMime(mime: string): boolean { // const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i'); // return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json'); // } // // public lookupCredential(key: string): string | undefined { // const value = this.credentials[key]; // return typeof value === 'function' // ? value() // : value; // } // // private defaultEncodeParam(param: Param): string { // // This implementation exists as fallback for missing configuration // // and for backwards compatibility to older typescript-angular generator versions. // // It only works for the 'simple' parameter style. // // Date-handling only works for the 'date-time' format. // // All other styles and Date-formats are probably handled incorrectly. // // // // But: if that's all you need (i.e.: the most common use-case): no need for customization! // // const value = param.dataFormat === 'date-time' && param.value instanceof Date // ? (param.value as Date).toISOString() // : param.value; // // return encodeURIComponent(String(value)); // } // // } // export class ApiConfiguration { // rootUrl: string = '//portal.openslice.io/osapi'; // } @Injectable({ providedIn: 'root', }) export class ApiConfiguration { rootUrl: string = '//portal.openslice.io/tmf-api'; } export class ApiConfiguration { rootUrl: string = '//portal.openslice.io/osapi'; export interface ApiConfigurationInterface { rootUrl?: string; } src/app/openApis/geographicSiteManagement/api.module.ts +40 −21 Original line number Diff line number Diff line import { NgModule, ModuleWithProviders, SkipSelf, Optional } from '@angular/core'; import { Configuration } from './configuration'; import { HttpClient } from '@angular/common/http'; import { NgModule, ModuleWithProviders} from '@angular/core'; import { ApiConfiguration, ApiConfigurationInterface } from './api-configuration'; import { HttpClientModule } from '@angular/common/http'; import { EventsSubscriptionService } from './services/events-subscription.service'; import { GeographicSiteService } from './services/geographicSite.service'; import { NotificationListenerService } from './services/notificationListener.service'; @NgModule({ imports: [], imports: [HttpClientModule], declarations: [], exports: [], providers: [] exports: [HttpClientModule], providers: [ ApiConfiguration, EventsSubscriptionService, GeographicSiteService, NotificationListenerService] }) export class ApiModule { public static forRoot(configurationFactory: () => Configuration): ModuleWithProviders<ApiModule> { static forRoot(customParams: ApiConfigurationInterface): ModuleWithProviders<ApiModule> { return { ngModule: ApiModule, providers: [ { provide: Configuration, useFactory: configurationFactory } ] }; providers: [ { provide: ApiConfiguration, useValue: {rootUrl: customParams.rootUrl} } constructor( @Optional() @SkipSelf() parentModule: ApiModule, @Optional() http: HttpClient) { if (parentModule) { throw new Error('ApiModule is already loaded. Import in your base AppModule only.'); } if (!http) { throw new Error('You need to import the HttpClientModule in your AppModule! \n' + 'See also https://github.com/angular/angular/issues/20575'); ] } } } // export class ApiModule { // public static forRoot(configurationFactory: () => Configuration): ModuleWithProviders<ApiModule> { // return { // ngModule: ApiModule, // providers: [ { provide: Configuration, useFactory: configurationFactory } ] // }; // } // // constructor( @Optional() @SkipSelf() parentModule: ApiModule, // @Optional() http: HttpClient) { // if (parentModule) { // throw new Error('ApiModule is already loaded. Import in your base AppModule only.'); // } // if (!http) { // throw new Error('You need to import the HttpClientModule in your AppModule! \n' + // 'See also https://github.com/angular/angular/issues/20575'); // } // } // } src/app/openApis/geographicSiteManagement/base-service.ts 0 → 100644 +63 −0 Original line number Diff line number Diff line /* tslint:disable */ import { HttpClient, HttpParameterCodec, HttpParams } from '@angular/common/http'; import { ApiConfiguration } from './api-configuration'; /** * Custom parameter codec to correctly handle the plus sign in parameter * values. See https://github.com/angular/angular/issues/18261 */ class ParameterCodec implements HttpParameterCodec { encodeKey(key: string): string { return encodeURIComponent(key); } encodeValue(value: string): string { return encodeURIComponent(value); } decodeKey(key: string): string { return decodeURIComponent(key); } decodeValue(value: string): string { return decodeURIComponent(value); } } const PARAMETER_CODEC = new ParameterCodec(); /** * Base class for API services */ export class BaseService { constructor( protected config: ApiConfiguration, protected http: HttpClient ) { } private _rootUrl: string = ''; /** * Returns the root url for API operations. If not set directly in this * service, will fallback to ApiConfiguration.rootUrl. */ get rootUrl(): string { return this._rootUrl || this.config.rootUrl; } /** * Sets the root URL for API operations in this service. */ set rootUrl(rootUrl: string) { this._rootUrl = rootUrl; } /** * Creates a new `HttpParams` with the correct codec */ protected newParams(): HttpParams { return new HttpParams({ encoder: PARAMETER_CODEC }); } } src/app/openApis/geographicSiteManagement/model/geographicAddressValue.ts +1 −1 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ export interface GeographicAddressValue extends PlaceRefOrValue { /** * When sub-classing, this defines the sub-class Extensible name */ type: string; type?: string; /** * When sub-classing, this defines the super-class */ Loading src/app/openApis/geographicSiteManagement/model/geographicSiteCreate.ts +1 −1 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ export interface GeographicSiteCreate { /** * When sub-classing, this defines the sub-class Extensible name */ type: string; '@type'?: string; /** * When sub-classing, this defines the super-class */ Loading Loading
src/app/openApis/geographicSiteManagement/api-configuration.ts +179 −164 Original line number Diff line number Diff line import { HttpParameterCodec } from '@angular/common/http'; import { Param } from './param'; import { Injectable, Inject } from '@angular/core'; export interface ConfigurationParameters { /** * @deprecated Since 5.0. Use credentials instead */ apiKeys?: {[ key: string ]: string}; username?: string; password?: string; /** * @deprecated Since 5.0. Use credentials instead */ accessToken?: string | (() => string); basePath?: string; withCredentials?: boolean; /** * Takes care of encoding query- and form-parameters. */ encoder?: HttpParameterCodec; /** * Override the default method for encoding path parameters in various * <a href="https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#style-values">styles</a>. * <p> * See {@link README.md} for more details * </p> */ encodeParam?: (param: Param) => string; /** * The keys are the names in the securitySchemes section of the OpenAPI * document. They should map to the value used for authentication * minus any standard prefixes such as 'Basic' or 'Bearer'. */ credentials?: {[ key: string ]: string | (() => string | undefined)}; } export class Configuration { /** * @deprecated Since 5.0. Use credentials instead */ apiKeys?: {[ key: string ]: string}; username?: string; password?: string; /** * @deprecated Since 5.0. Use credentials instead */ accessToken?: string | (() => string); basePath?: string; withCredentials?: boolean; /** * Takes care of encoding query- and form-parameters. */ encoder?: HttpParameterCodec; /** * Encoding of various path parameter * <a href="https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#style-values">styles</a>. * <p> * See {@link README.md} for more details * </p> */ encodeParam: (param: Param) => string; /** * The keys are the names in the securitySchemes section of the OpenAPI * document. They should map to the value used for authentication * minus any standard prefixes such as 'Basic' or 'Bearer'. */ credentials: {[ key: string ]: string | (() => string | undefined)}; constructor(configurationParameters: ConfigurationParameters = {}) { this.apiKeys = configurationParameters.apiKeys; this.username = configurationParameters.username; this.password = configurationParameters.password; this.accessToken = configurationParameters.accessToken; this.basePath = configurationParameters.basePath; this.withCredentials = configurationParameters.withCredentials; this.encoder = configurationParameters.encoder; if (configurationParameters.encodeParam) { this.encodeParam = configurationParameters.encodeParam; } else { this.encodeParam = param => this.defaultEncodeParam(param); } if (configurationParameters.credentials) { this.credentials = configurationParameters.credentials; } else { this.credentials = {}; } } /** * Select the correct content-type to use for a request. * Uses {@link Configuration#isJsonMime} to determine the correct content-type. * If no content type is found return the first found type if the contentTypes is not empty * @param contentTypes - the array of content types that are available for selection * @returns the selected content-type or <code>undefined</code> if no selection could be made. */ public selectHeaderContentType (contentTypes: string[]): string | undefined { if (contentTypes.length === 0) { return undefined; } const type = contentTypes.find((x: string) => this.isJsonMime(x)); if (type === undefined) { return contentTypes[0]; } return type; } /** * Select the correct accept content-type to use for a request. * Uses {@link Configuration#isJsonMime} to determine the correct accept content-type. * If no content type is found return the first found type if the contentTypes is not empty * @param accepts - the array of content types that are available for selection. * @returns the selected content-type or <code>undefined</code> if no selection could be made. */ public selectHeaderAccept(accepts: string[]): string | undefined { if (accepts.length === 0) { return undefined; } const type = accepts.find((x: string) => this.isJsonMime(x)); if (type === undefined) { return accepts[0]; } return type; } /** * Check if the given MIME is a JSON MIME. * JSON MIME examples: * application/json * application/json; charset=UTF8 * APPLICATION/JSON * application/vnd.company+json * @param mime - MIME (Multipurpose Internet Mail Extensions) * @return True if the given MIME is JSON, false otherwise. */ public isJsonMime(mime: string): boolean { const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i'); return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json'); } public lookupCredential(key: string): string | undefined { const value = this.credentials[key]; return typeof value === 'function' ? value() : value; } private defaultEncodeParam(param: Param): string { // This implementation exists as fallback for missing configuration // and for backwards compatibility to older typescript-angular generator versions. // It only works for the 'simple' parameter style. // Date-handling only works for the 'date-time' format. // All other styles and Date-formats are probably handled incorrectly. // export interface ConfigurationParameters { // /** // * @deprecated Since 5.0. Use credentials instead // */ // apiKeys?: {[ key: string ]: string}; // username?: string; // password?: string; // /** // * @deprecated Since 5.0. Use credentials instead // */ // accessToken?: string | (() => string); // basePath?: string; // withCredentials?: boolean; // /** // * Takes care of encoding query- and form-parameters. // */ // encoder?: HttpParameterCodec; // /** // * Override the default method for encoding path parameters in various // * <a href="https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#style-values">styles</a>. // * <p> // * See {@link README.md} for more details // * </p> // */ // encodeParam?: (param: Param) => string; // /** // * The keys are the names in the securitySchemes section of the OpenAPI // * document. They should map to the value used for authentication // * minus any standard prefixes such as 'Basic' or 'Bearer'. // */ // credentials?: {[ key: string ]: string | (() => string | undefined)}; // } // // But: if that's all you need (i.e.: the most common use-case): no need for customization! const value = param.dataFormat === 'date-time' && param.value instanceof Date ? (param.value as Date).toISOString() : param.value; return encodeURIComponent(String(value)); } // @Injectable({ // providedIn: 'root', // }) // export class ApiConfiguration { // /** // * @deprecated Since 5.0. Use credentials instead // */ // apiKeys?: {[ key: string ]: string}; // username?: string; // password?: string; // /** // * @deprecated Since 5.0. Use credentials instead // */ // accessToken?: string | (() => string); // basePath?: string; // withCredentials?: boolean; // /** // * Takes care of encoding query- and form-parameters. // */ // encoder?: HttpParameterCodec; // /** // * Encoding of various path parameter // * <a href="https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#style-values">styles</a>. // * <p> // * See {@link README.md} for more details // * </p> // */ // encodeParam: (param: Param) => string; // /** // * The keys are the names in the securitySchemes section of the OpenAPI // * document. They should map to the value used for authentication // * minus any standard prefixes such as 'Basic' or 'Bearer'. // */ // credentials: {[ key: string ]: string | (() => string | undefined)}; // // constructor(configurationParameters: ConfigurationParameters = {}) { // this.apiKeys = configurationParameters.apiKeys; // this.username = configurationParameters.username; // this.password = configurationParameters.password; // this.accessToken = configurationParameters.accessToken; // this.basePath = configurationParameters.basePath; // this.withCredentials = configurationParameters.withCredentials; // this.encoder = configurationParameters.encoder; // if (configurationParameters.encodeParam) { // this.encodeParam = configurationParameters.encodeParam; // } // else { // this.encodeParam = param => this.defaultEncodeParam(param); // } // if (configurationParameters.credentials) { // this.credentials = configurationParameters.credentials; // } // else { // this.credentials = {}; // } // } // // /** // * Select the correct content-type to use for a request. // * Uses {@link Configuration#isJsonMime} to determine the correct content-type. // * If no content type is found return the first found type if the contentTypes is not empty // * @param contentTypes - the array of content types that are available for selection // * @returns the selected content-type or <code>undefined</code> if no selection could be made. // */ // public selectHeaderContentType (contentTypes: string[]): string | undefined { // if (contentTypes.length === 0) { // return undefined; // } // // const type = contentTypes.find((x: string) => this.isJsonMime(x)); // if (type === undefined) { // return contentTypes[0]; // } // return type; // } // // /** // * Select the correct accept content-type to use for a request. // * Uses {@link Configuration#isJsonMime} to determine the correct accept content-type. // * If no content type is found return the first found type if the contentTypes is not empty // * @param accepts - the array of content types that are available for selection. // * @returns the selected content-type or <code>undefined</code> if no selection could be made. // */ // public selectHeaderAccept(accepts: string[]): string | undefined { // if (accepts.length === 0) { // return undefined; // } // // const type = accepts.find((x: string) => this.isJsonMime(x)); // if (type === undefined) { // return accepts[0]; // } // return type; // } // // /** // * Check if the given MIME is a JSON MIME. // * JSON MIME examples: // * application/json // * application/json; charset=UTF8 // * APPLICATION/JSON // * application/vnd.company+json // * @param mime - MIME (Multipurpose Internet Mail Extensions) // * @return True if the given MIME is JSON, false otherwise. // */ // public isJsonMime(mime: string): boolean { // const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i'); // return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json'); // } // // public lookupCredential(key: string): string | undefined { // const value = this.credentials[key]; // return typeof value === 'function' // ? value() // : value; // } // // private defaultEncodeParam(param: Param): string { // // This implementation exists as fallback for missing configuration // // and for backwards compatibility to older typescript-angular generator versions. // // It only works for the 'simple' parameter style. // // Date-handling only works for the 'date-time' format. // // All other styles and Date-formats are probably handled incorrectly. // // // // But: if that's all you need (i.e.: the most common use-case): no need for customization! // // const value = param.dataFormat === 'date-time' && param.value instanceof Date // ? (param.value as Date).toISOString() // : param.value; // // return encodeURIComponent(String(value)); // } // // } // export class ApiConfiguration { // rootUrl: string = '//portal.openslice.io/osapi'; // } @Injectable({ providedIn: 'root', }) export class ApiConfiguration { rootUrl: string = '//portal.openslice.io/tmf-api'; } export class ApiConfiguration { rootUrl: string = '//portal.openslice.io/osapi'; export interface ApiConfigurationInterface { rootUrl?: string; }
src/app/openApis/geographicSiteManagement/api.module.ts +40 −21 Original line number Diff line number Diff line import { NgModule, ModuleWithProviders, SkipSelf, Optional } from '@angular/core'; import { Configuration } from './configuration'; import { HttpClient } from '@angular/common/http'; import { NgModule, ModuleWithProviders} from '@angular/core'; import { ApiConfiguration, ApiConfigurationInterface } from './api-configuration'; import { HttpClientModule } from '@angular/common/http'; import { EventsSubscriptionService } from './services/events-subscription.service'; import { GeographicSiteService } from './services/geographicSite.service'; import { NotificationListenerService } from './services/notificationListener.service'; @NgModule({ imports: [], imports: [HttpClientModule], declarations: [], exports: [], providers: [] exports: [HttpClientModule], providers: [ ApiConfiguration, EventsSubscriptionService, GeographicSiteService, NotificationListenerService] }) export class ApiModule { public static forRoot(configurationFactory: () => Configuration): ModuleWithProviders<ApiModule> { static forRoot(customParams: ApiConfigurationInterface): ModuleWithProviders<ApiModule> { return { ngModule: ApiModule, providers: [ { provide: Configuration, useFactory: configurationFactory } ] }; providers: [ { provide: ApiConfiguration, useValue: {rootUrl: customParams.rootUrl} } constructor( @Optional() @SkipSelf() parentModule: ApiModule, @Optional() http: HttpClient) { if (parentModule) { throw new Error('ApiModule is already loaded. Import in your base AppModule only.'); } if (!http) { throw new Error('You need to import the HttpClientModule in your AppModule! \n' + 'See also https://github.com/angular/angular/issues/20575'); ] } } } // export class ApiModule { // public static forRoot(configurationFactory: () => Configuration): ModuleWithProviders<ApiModule> { // return { // ngModule: ApiModule, // providers: [ { provide: Configuration, useFactory: configurationFactory } ] // }; // } // // constructor( @Optional() @SkipSelf() parentModule: ApiModule, // @Optional() http: HttpClient) { // if (parentModule) { // throw new Error('ApiModule is already loaded. Import in your base AppModule only.'); // } // if (!http) { // throw new Error('You need to import the HttpClientModule in your AppModule! \n' + // 'See also https://github.com/angular/angular/issues/20575'); // } // } // }
src/app/openApis/geographicSiteManagement/base-service.ts 0 → 100644 +63 −0 Original line number Diff line number Diff line /* tslint:disable */ import { HttpClient, HttpParameterCodec, HttpParams } from '@angular/common/http'; import { ApiConfiguration } from './api-configuration'; /** * Custom parameter codec to correctly handle the plus sign in parameter * values. See https://github.com/angular/angular/issues/18261 */ class ParameterCodec implements HttpParameterCodec { encodeKey(key: string): string { return encodeURIComponent(key); } encodeValue(value: string): string { return encodeURIComponent(value); } decodeKey(key: string): string { return decodeURIComponent(key); } decodeValue(value: string): string { return decodeURIComponent(value); } } const PARAMETER_CODEC = new ParameterCodec(); /** * Base class for API services */ export class BaseService { constructor( protected config: ApiConfiguration, protected http: HttpClient ) { } private _rootUrl: string = ''; /** * Returns the root url for API operations. If not set directly in this * service, will fallback to ApiConfiguration.rootUrl. */ get rootUrl(): string { return this._rootUrl || this.config.rootUrl; } /** * Sets the root URL for API operations in this service. */ set rootUrl(rootUrl: string) { this._rootUrl = rootUrl; } /** * Creates a new `HttpParams` with the correct codec */ protected newParams(): HttpParams { return new HttpParams({ encoder: PARAMETER_CODEC }); } }
src/app/openApis/geographicSiteManagement/model/geographicAddressValue.ts +1 −1 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ export interface GeographicAddressValue extends PlaceRefOrValue { /** * When sub-classing, this defines the sub-class Extensible name */ type: string; type?: string; /** * When sub-classing, this defines the super-class */ Loading
src/app/openApis/geographicSiteManagement/model/geographicSiteCreate.ts +1 −1 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ export interface GeographicSiteCreate { /** * When sub-classing, this defines the sub-class Extensible name */ type: string; '@type'?: string; /** * When sub-classing, this defines the super-class */ Loading