API module
This commit is contained in:
parent
d490493b1d
commit
bc512fe0a5
16
api/pom.xml
16
api/pom.xml
|
@ -140,6 +140,7 @@
|
||||||
<version>${openapi-generator.version}</version>
|
<version>${openapi-generator.version}</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
|
<id>generate-server</id>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>generate</goal>
|
<goal>generate</goal>
|
||||||
</goals>
|
</goals>
|
||||||
|
@ -159,6 +160,21 @@
|
||||||
</configOptions>
|
</configOptions>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>generate-client</id>
|
||||||
|
<goals>
|
||||||
|
<goal>generate</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<skipValidateSpec>true</skipValidateSpec>
|
||||||
|
<inputSpec>../doc/api/openapi/openapi.yaml</inputSpec>
|
||||||
|
<generatorName>typescript-angular</generatorName>
|
||||||
|
<output>../ng-client</output>
|
||||||
|
<configOptions>
|
||||||
|
<npmName>recettes-ng-client</npmName>
|
||||||
|
</configOptions>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
wwwroot/*.js
|
||||||
|
node_modules
|
||||||
|
typings
|
||||||
|
dist
|
|
@ -0,0 +1,3 @@
|
||||||
|
# OpenAPI Generator Ignore
|
||||||
|
git_push.sh
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
.gitignore
|
||||||
|
README.md
|
||||||
|
api.module.ts
|
||||||
|
api/api.ts
|
||||||
|
api/parameter.service.ts
|
||||||
|
api/receipe.service.ts
|
||||||
|
configuration.ts
|
||||||
|
encoder.ts
|
||||||
|
index.ts
|
||||||
|
model/ingredient.ts
|
||||||
|
model/models.ts
|
||||||
|
model/quantity.ts
|
||||||
|
model/receipe.ts
|
||||||
|
model/receipeReceipeYield.ts
|
||||||
|
model/recetteParam.ts
|
||||||
|
model/step.ts
|
||||||
|
ng-package.json
|
||||||
|
package.json
|
||||||
|
param.ts
|
||||||
|
tsconfig.json
|
||||||
|
variables.ts
|
|
@ -0,0 +1 @@
|
||||||
|
6.2.1
|
|
@ -0,0 +1 @@
|
||||||
|
bcd2df10b94c68026e7d319245060c8fe5bf7ccd7d126afc86aa3c2cddf5f9a1
|
|
@ -0,0 +1,226 @@
|
||||||
|
## recettes-ng-client@1.0.0
|
||||||
|
|
||||||
|
### Building
|
||||||
|
|
||||||
|
To install the required dependencies and to build the typescript sources run:
|
||||||
|
```
|
||||||
|
npm install
|
||||||
|
npm run build
|
||||||
|
```
|
||||||
|
|
||||||
|
### publishing
|
||||||
|
|
||||||
|
First build the package then run ```npm publish dist``` (don't forget to specify the `dist` folder!)
|
||||||
|
|
||||||
|
### consuming
|
||||||
|
|
||||||
|
Navigate to the folder of your consuming project and run one of next commands.
|
||||||
|
|
||||||
|
_published:_
|
||||||
|
|
||||||
|
```
|
||||||
|
npm install recettes-ng-client@1.0.0 --save
|
||||||
|
```
|
||||||
|
|
||||||
|
_without publishing (not recommended):_
|
||||||
|
|
||||||
|
```
|
||||||
|
npm install PATH_TO_GENERATED_PACKAGE/dist.tgz --save
|
||||||
|
```
|
||||||
|
|
||||||
|
_It's important to take the tgz file, otherwise you'll get trouble with links on windows_
|
||||||
|
|
||||||
|
_using `npm link`:_
|
||||||
|
|
||||||
|
In PATH_TO_GENERATED_PACKAGE/dist:
|
||||||
|
```
|
||||||
|
npm link
|
||||||
|
```
|
||||||
|
|
||||||
|
In your project:
|
||||||
|
```
|
||||||
|
npm link recettes-ng-client
|
||||||
|
```
|
||||||
|
|
||||||
|
__Note for Windows users:__ The Angular CLI has troubles to use linked npm packages.
|
||||||
|
Please refer to this issue https://github.com/angular/angular-cli/issues/8284 for a solution / workaround.
|
||||||
|
Published packages are not effected by this issue.
|
||||||
|
|
||||||
|
|
||||||
|
#### General usage
|
||||||
|
|
||||||
|
In your Angular project:
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
// without configuring providers
|
||||||
|
import { ApiModule } from 'recettes-ng-client';
|
||||||
|
import { HttpClientModule } from '@angular/common/http';
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [
|
||||||
|
ApiModule,
|
||||||
|
// make sure to import the HttpClientModule in the AppModule only,
|
||||||
|
// see https://github.com/angular/angular/issues/20575
|
||||||
|
HttpClientModule
|
||||||
|
],
|
||||||
|
declarations: [ AppComponent ],
|
||||||
|
providers: [],
|
||||||
|
bootstrap: [ AppComponent ]
|
||||||
|
})
|
||||||
|
export class AppModule {}
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
// configuring providers
|
||||||
|
import { ApiModule, Configuration, ConfigurationParameters } from 'recettes-ng-client';
|
||||||
|
|
||||||
|
export function apiConfigFactory (): Configuration {
|
||||||
|
const params: ConfigurationParameters = {
|
||||||
|
// set configuration parameters here.
|
||||||
|
}
|
||||||
|
return new Configuration(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [ ApiModule.forRoot(apiConfigFactory) ],
|
||||||
|
declarations: [ AppComponent ],
|
||||||
|
providers: [],
|
||||||
|
bootstrap: [ AppComponent ]
|
||||||
|
})
|
||||||
|
export class AppModule {}
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
// configuring providers with an authentication service that manages your access tokens
|
||||||
|
import { ApiModule, Configuration } from 'recettes-ng-client';
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [ ApiModule ],
|
||||||
|
declarations: [ AppComponent ],
|
||||||
|
providers: [
|
||||||
|
{
|
||||||
|
provide: Configuration,
|
||||||
|
useFactory: (authService: AuthService) => new Configuration(
|
||||||
|
{
|
||||||
|
basePath: environment.apiUrl,
|
||||||
|
accessToken: authService.getAccessToken.bind(authService)
|
||||||
|
}
|
||||||
|
),
|
||||||
|
deps: [AuthService],
|
||||||
|
multi: false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
bootstrap: [ AppComponent ]
|
||||||
|
})
|
||||||
|
export class AppModule {}
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
import { DefaultApi } from 'recettes-ng-client';
|
||||||
|
|
||||||
|
export class AppComponent {
|
||||||
|
constructor(private apiGateway: DefaultApi) { }
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Note: The ApiModule is restricted to being instantiated once app wide.
|
||||||
|
This is to ensure that all services are treated as singletons.
|
||||||
|
|
||||||
|
#### Using multiple OpenAPI files / APIs / ApiModules
|
||||||
|
In order to use multiple `ApiModules` generated from different OpenAPI files,
|
||||||
|
you can create an alias name when importing the modules
|
||||||
|
in order to avoid naming conflicts:
|
||||||
|
```
|
||||||
|
import { ApiModule } from 'my-api-path';
|
||||||
|
import { ApiModule as OtherApiModule } from 'my-other-api-path';
|
||||||
|
import { HttpClientModule } from '@angular/common/http';
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [
|
||||||
|
ApiModule,
|
||||||
|
OtherApiModule,
|
||||||
|
// make sure to import the HttpClientModule in the AppModule only,
|
||||||
|
// see https://github.com/angular/angular/issues/20575
|
||||||
|
HttpClientModule
|
||||||
|
]
|
||||||
|
})
|
||||||
|
export class AppModule {
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Set service base path
|
||||||
|
If different than the generated base path, during app bootstrap, you can provide the base path to your service.
|
||||||
|
|
||||||
|
```
|
||||||
|
import { BASE_PATH } from 'recettes-ng-client';
|
||||||
|
|
||||||
|
bootstrap(AppComponent, [
|
||||||
|
{ provide: BASE_PATH, useValue: 'https://your-web-service.com' },
|
||||||
|
]);
|
||||||
|
```
|
||||||
|
or
|
||||||
|
|
||||||
|
```
|
||||||
|
import { BASE_PATH } from 'recettes-ng-client';
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [],
|
||||||
|
declarations: [ AppComponent ],
|
||||||
|
providers: [ provide: BASE_PATH, useValue: 'https://your-web-service.com' ],
|
||||||
|
bootstrap: [ AppComponent ]
|
||||||
|
})
|
||||||
|
export class AppModule {}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
#### Using @angular/cli
|
||||||
|
First extend your `src/environments/*.ts` files by adding the corresponding base path:
|
||||||
|
|
||||||
|
```
|
||||||
|
export const environment = {
|
||||||
|
production: false,
|
||||||
|
API_BASE_PATH: 'http://127.0.0.1:8080'
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
In the src/app/app.module.ts:
|
||||||
|
```
|
||||||
|
import { BASE_PATH } from 'recettes-ng-client';
|
||||||
|
import { environment } from '../environments/environment';
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
declarations: [
|
||||||
|
AppComponent
|
||||||
|
],
|
||||||
|
imports: [ ],
|
||||||
|
providers: [{ provide: BASE_PATH, useValue: environment.API_BASE_PATH }],
|
||||||
|
bootstrap: [ AppComponent ]
|
||||||
|
})
|
||||||
|
export class AppModule { }
|
||||||
|
```
|
||||||
|
|
||||||
|
### Customizing path parameter encoding
|
||||||
|
|
||||||
|
Without further customization, only [path-parameters][parameter-locations-url] of [style][style-values-url] 'simple'
|
||||||
|
and Dates for format 'date-time' are encoded correctly.
|
||||||
|
|
||||||
|
Other styles (e.g. "matrix") are not that easy to encode
|
||||||
|
and thus are best delegated to other libraries (e.g.: [@honoluluhenk/http-param-expander]).
|
||||||
|
|
||||||
|
To implement your own parameter encoding (or call another library),
|
||||||
|
pass an arrow-function or method-reference to the `encodeParam` property of the Configuration-object
|
||||||
|
(see [General Usage](#general-usage) above).
|
||||||
|
|
||||||
|
Example value for use in your Configuration-Provider:
|
||||||
|
```typescript
|
||||||
|
new Configuration({
|
||||||
|
encodeParam: (param: Param) => myFancyParamEncoder(param),
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
[parameter-locations-url]: https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#parameter-locations
|
||||||
|
[style-values-url]: https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#style-values
|
||||||
|
[@honoluluhenk/http-param-expander]: https://www.npmjs.com/package/@honoluluhenk/http-param-expander
|
|
@ -0,0 +1,32 @@
|
||||||
|
import { NgModule, ModuleWithProviders, SkipSelf, Optional } from '@angular/core';
|
||||||
|
import { Configuration } from './configuration';
|
||||||
|
import { HttpClient } from '@angular/common/http';
|
||||||
|
|
||||||
|
import { ParameterService } from './api/parameter.service';
|
||||||
|
import { ReceipeService } from './api/receipe.service';
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [],
|
||||||
|
declarations: [],
|
||||||
|
exports: [],
|
||||||
|
providers: []
|
||||||
|
})
|
||||||
|
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');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
export * from './parameter.service';
|
||||||
|
import { ParameterService } from './parameter.service';
|
||||||
|
export * from './receipe.service';
|
||||||
|
import { ReceipeService } from './receipe.service';
|
||||||
|
export const APIS = [ParameterService, ReceipeService];
|
|
@ -0,0 +1,153 @@
|
||||||
|
/**
|
||||||
|
* Recettes - OpenAPI 3.0
|
||||||
|
* API recettes
|
||||||
|
*
|
||||||
|
* The version of the OpenAPI document: 1.0.0
|
||||||
|
* Contact: meutel@meutel.net
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
/* tslint:disable:no-unused-variable member-ordering */
|
||||||
|
|
||||||
|
import { Inject, Injectable, Optional } from '@angular/core';
|
||||||
|
import { HttpClient, HttpHeaders, HttpParams,
|
||||||
|
HttpResponse, HttpEvent, HttpParameterCodec, HttpContext
|
||||||
|
} from '@angular/common/http';
|
||||||
|
import { CustomHttpParameterCodec } from '../encoder';
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
|
import { RecetteParam } from '../model/recetteParam';
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
|
import { BASE_PATH, COLLECTION_FORMATS } from '../variables';
|
||||||
|
import { Configuration } from '../configuration';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class ParameterService {
|
||||||
|
|
||||||
|
protected basePath = 'https://recettes.meutel.net/api/v1';
|
||||||
|
public defaultHeaders = new HttpHeaders();
|
||||||
|
public configuration = new Configuration();
|
||||||
|
public encoder: HttpParameterCodec;
|
||||||
|
|
||||||
|
constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string|string[], @Optional() configuration: Configuration) {
|
||||||
|
if (configuration) {
|
||||||
|
this.configuration = configuration;
|
||||||
|
}
|
||||||
|
if (typeof this.configuration.basePath !== 'string') {
|
||||||
|
if (Array.isArray(basePath) && basePath.length > 0) {
|
||||||
|
basePath = basePath[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof basePath !== 'string') {
|
||||||
|
basePath = this.basePath;
|
||||||
|
}
|
||||||
|
this.configuration.basePath = basePath;
|
||||||
|
}
|
||||||
|
this.encoder = this.configuration.encoder || new CustomHttpParameterCodec();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
|
private addToHttpParams(httpParams: HttpParams, value: any, key?: string): HttpParams {
|
||||||
|
if (typeof value === "object" && value instanceof Date === false) {
|
||||||
|
httpParams = this.addToHttpParamsRecursive(httpParams, value);
|
||||||
|
} else {
|
||||||
|
httpParams = this.addToHttpParamsRecursive(httpParams, value, key);
|
||||||
|
}
|
||||||
|
return httpParams;
|
||||||
|
}
|
||||||
|
|
||||||
|
private addToHttpParamsRecursive(httpParams: HttpParams, value?: any, key?: string): HttpParams {
|
||||||
|
if (value == null) {
|
||||||
|
return httpParams;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof value === "object") {
|
||||||
|
if (Array.isArray(value)) {
|
||||||
|
(value as any[]).forEach( elem => httpParams = this.addToHttpParamsRecursive(httpParams, elem, key));
|
||||||
|
} else if (value instanceof Date) {
|
||||||
|
if (key != null) {
|
||||||
|
httpParams = httpParams.append(key, (value as Date).toISOString().substr(0, 10));
|
||||||
|
} else {
|
||||||
|
throw Error("key may not be null if value is Date");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Object.keys(value).forEach( k => httpParams = this.addToHttpParamsRecursive(
|
||||||
|
httpParams, value[k], key != null ? `${key}.${k}` : k));
|
||||||
|
}
|
||||||
|
} else if (key != null) {
|
||||||
|
httpParams = httpParams.append(key, value);
|
||||||
|
} else {
|
||||||
|
throw Error("key may not be null if value is not object or array");
|
||||||
|
}
|
||||||
|
return httpParams;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parameters by type
|
||||||
|
* Returns a list of parameters of given type
|
||||||
|
* @param paramType Type of parameters to return
|
||||||
|
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
|
||||||
|
* @param reportProgress flag to report request and response progress.
|
||||||
|
*/
|
||||||
|
public listRecetteParamsByType(paramType: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<Array<RecetteParam>>;
|
||||||
|
public listRecetteParamsByType(paramType: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<HttpResponse<Array<RecetteParam>>>;
|
||||||
|
public listRecetteParamsByType(paramType: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<HttpEvent<Array<RecetteParam>>>;
|
||||||
|
public listRecetteParamsByType(paramType: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<any> {
|
||||||
|
if (paramType === null || paramType === undefined) {
|
||||||
|
throw new Error('Required parameter paramType was null or undefined when calling listRecetteParamsByType.');
|
||||||
|
}
|
||||||
|
|
||||||
|
let localVarHeaders = this.defaultHeaders;
|
||||||
|
|
||||||
|
let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
|
||||||
|
if (localVarHttpHeaderAcceptSelected === undefined) {
|
||||||
|
// to determine the Accept header
|
||||||
|
const httpHeaderAccepts: string[] = [
|
||||||
|
'application/json'
|
||||||
|
];
|
||||||
|
localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||||
|
}
|
||||||
|
if (localVarHttpHeaderAcceptSelected !== undefined) {
|
||||||
|
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
|
||||||
|
}
|
||||||
|
|
||||||
|
let localVarHttpContext: HttpContext | undefined = options && options.context;
|
||||||
|
if (localVarHttpContext === undefined) {
|
||||||
|
localVarHttpContext = new HttpContext();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
let responseType_: 'text' | 'json' | 'blob' = 'json';
|
||||||
|
if (localVarHttpHeaderAcceptSelected) {
|
||||||
|
if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
|
||||||
|
responseType_ = 'text';
|
||||||
|
} else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
|
||||||
|
responseType_ = 'json';
|
||||||
|
} else {
|
||||||
|
responseType_ = 'blob';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let localVarPath = `/parameters/${this.configuration.encodeParam({name: "paramType", value: paramType, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}`;
|
||||||
|
return this.httpClient.request<Array<RecetteParam>>('get', `${this.configuration.basePath}${localVarPath}`,
|
||||||
|
{
|
||||||
|
context: localVarHttpContext,
|
||||||
|
responseType: <any>responseType_,
|
||||||
|
withCredentials: this.configuration.withCredentials,
|
||||||
|
headers: localVarHeaders,
|
||||||
|
observe: observe,
|
||||||
|
reportProgress: reportProgress
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,208 @@
|
||||||
|
/**
|
||||||
|
* Recettes - OpenAPI 3.0
|
||||||
|
* API recettes
|
||||||
|
*
|
||||||
|
* The version of the OpenAPI document: 1.0.0
|
||||||
|
* Contact: meutel@meutel.net
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
/* tslint:disable:no-unused-variable member-ordering */
|
||||||
|
|
||||||
|
import { Inject, Injectable, Optional } from '@angular/core';
|
||||||
|
import { HttpClient, HttpHeaders, HttpParams,
|
||||||
|
HttpResponse, HttpEvent, HttpParameterCodec, HttpContext
|
||||||
|
} from '@angular/common/http';
|
||||||
|
import { CustomHttpParameterCodec } from '../encoder';
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
|
import { Receipe } from '../model/receipe';
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
|
import { BASE_PATH, COLLECTION_FORMATS } from '../variables';
|
||||||
|
import { Configuration } from '../configuration';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class ReceipeService {
|
||||||
|
|
||||||
|
protected basePath = 'https://recettes.meutel.net/api/v1';
|
||||||
|
public defaultHeaders = new HttpHeaders();
|
||||||
|
public configuration = new Configuration();
|
||||||
|
public encoder: HttpParameterCodec;
|
||||||
|
|
||||||
|
constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string|string[], @Optional() configuration: Configuration) {
|
||||||
|
if (configuration) {
|
||||||
|
this.configuration = configuration;
|
||||||
|
}
|
||||||
|
if (typeof this.configuration.basePath !== 'string') {
|
||||||
|
if (Array.isArray(basePath) && basePath.length > 0) {
|
||||||
|
basePath = basePath[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof basePath !== 'string') {
|
||||||
|
basePath = this.basePath;
|
||||||
|
}
|
||||||
|
this.configuration.basePath = basePath;
|
||||||
|
}
|
||||||
|
this.encoder = this.configuration.encoder || new CustomHttpParameterCodec();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
|
private addToHttpParams(httpParams: HttpParams, value: any, key?: string): HttpParams {
|
||||||
|
if (typeof value === "object" && value instanceof Date === false) {
|
||||||
|
httpParams = this.addToHttpParamsRecursive(httpParams, value);
|
||||||
|
} else {
|
||||||
|
httpParams = this.addToHttpParamsRecursive(httpParams, value, key);
|
||||||
|
}
|
||||||
|
return httpParams;
|
||||||
|
}
|
||||||
|
|
||||||
|
private addToHttpParamsRecursive(httpParams: HttpParams, value?: any, key?: string): HttpParams {
|
||||||
|
if (value == null) {
|
||||||
|
return httpParams;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof value === "object") {
|
||||||
|
if (Array.isArray(value)) {
|
||||||
|
(value as any[]).forEach( elem => httpParams = this.addToHttpParamsRecursive(httpParams, elem, key));
|
||||||
|
} else if (value instanceof Date) {
|
||||||
|
if (key != null) {
|
||||||
|
httpParams = httpParams.append(key, (value as Date).toISOString().substr(0, 10));
|
||||||
|
} else {
|
||||||
|
throw Error("key may not be null if value is Date");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Object.keys(value).forEach( k => httpParams = this.addToHttpParamsRecursive(
|
||||||
|
httpParams, value[k], key != null ? `${key}.${k}` : k));
|
||||||
|
}
|
||||||
|
} else if (key != null) {
|
||||||
|
httpParams = httpParams.append(key, value);
|
||||||
|
} else {
|
||||||
|
throw Error("key may not be null if value is not object or array");
|
||||||
|
}
|
||||||
|
return httpParams;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lists receipes
|
||||||
|
* Lists and search receipes
|
||||||
|
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
|
||||||
|
* @param reportProgress flag to report request and response progress.
|
||||||
|
*/
|
||||||
|
public findReceipes(observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<Array<Receipe>>;
|
||||||
|
public findReceipes(observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<HttpResponse<Array<Receipe>>>;
|
||||||
|
public findReceipes(observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<HttpEvent<Array<Receipe>>>;
|
||||||
|
public findReceipes(observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<any> {
|
||||||
|
|
||||||
|
let localVarHeaders = this.defaultHeaders;
|
||||||
|
|
||||||
|
let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
|
||||||
|
if (localVarHttpHeaderAcceptSelected === undefined) {
|
||||||
|
// to determine the Accept header
|
||||||
|
const httpHeaderAccepts: string[] = [
|
||||||
|
'application/json'
|
||||||
|
];
|
||||||
|
localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||||
|
}
|
||||||
|
if (localVarHttpHeaderAcceptSelected !== undefined) {
|
||||||
|
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
|
||||||
|
}
|
||||||
|
|
||||||
|
let localVarHttpContext: HttpContext | undefined = options && options.context;
|
||||||
|
if (localVarHttpContext === undefined) {
|
||||||
|
localVarHttpContext = new HttpContext();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
let responseType_: 'text' | 'json' | 'blob' = 'json';
|
||||||
|
if (localVarHttpHeaderAcceptSelected) {
|
||||||
|
if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
|
||||||
|
responseType_ = 'text';
|
||||||
|
} else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
|
||||||
|
responseType_ = 'json';
|
||||||
|
} else {
|
||||||
|
responseType_ = 'blob';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let localVarPath = `/receipes`;
|
||||||
|
return this.httpClient.request<Array<Receipe>>('get', `${this.configuration.basePath}${localVarPath}`,
|
||||||
|
{
|
||||||
|
context: localVarHttpContext,
|
||||||
|
responseType: <any>responseType_,
|
||||||
|
withCredentials: this.configuration.withCredentials,
|
||||||
|
headers: localVarHeaders,
|
||||||
|
observe: observe,
|
||||||
|
reportProgress: reportProgress
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find receipe by ID
|
||||||
|
* Returns a single receipe
|
||||||
|
* @param receipeId ID of receipe to return
|
||||||
|
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
|
||||||
|
* @param reportProgress flag to report request and response progress.
|
||||||
|
*/
|
||||||
|
public getReceipeById(receipeId: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<Receipe>;
|
||||||
|
public getReceipeById(receipeId: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<HttpResponse<Receipe>>;
|
||||||
|
public getReceipeById(receipeId: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<HttpEvent<Receipe>>;
|
||||||
|
public getReceipeById(receipeId: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<any> {
|
||||||
|
if (receipeId === null || receipeId === undefined) {
|
||||||
|
throw new Error('Required parameter receipeId was null or undefined when calling getReceipeById.');
|
||||||
|
}
|
||||||
|
|
||||||
|
let localVarHeaders = this.defaultHeaders;
|
||||||
|
|
||||||
|
let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
|
||||||
|
if (localVarHttpHeaderAcceptSelected === undefined) {
|
||||||
|
// to determine the Accept header
|
||||||
|
const httpHeaderAccepts: string[] = [
|
||||||
|
'application/json'
|
||||||
|
];
|
||||||
|
localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||||
|
}
|
||||||
|
if (localVarHttpHeaderAcceptSelected !== undefined) {
|
||||||
|
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
|
||||||
|
}
|
||||||
|
|
||||||
|
let localVarHttpContext: HttpContext | undefined = options && options.context;
|
||||||
|
if (localVarHttpContext === undefined) {
|
||||||
|
localVarHttpContext = new HttpContext();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
let responseType_: 'text' | 'json' | 'blob' = 'json';
|
||||||
|
if (localVarHttpHeaderAcceptSelected) {
|
||||||
|
if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
|
||||||
|
responseType_ = 'text';
|
||||||
|
} else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
|
||||||
|
responseType_ = 'json';
|
||||||
|
} else {
|
||||||
|
responseType_ = 'blob';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let localVarPath = `/receipes/${this.configuration.encodeParam({name: "receipeId", value: receipeId, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}`;
|
||||||
|
return this.httpClient.request<Receipe>('get', `${this.configuration.basePath}${localVarPath}`,
|
||||||
|
{
|
||||||
|
context: localVarHttpContext,
|
||||||
|
responseType: <any>responseType_,
|
||||||
|
withCredentials: this.configuration.withCredentials,
|
||||||
|
headers: localVarHeaders,
|
||||||
|
observe: observe,
|
||||||
|
reportProgress: reportProgress
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,166 @@
|
||||||
|
import { HttpParameterCodec } from '@angular/common/http';
|
||||||
|
import { Param } from './param';
|
||||||
|
|
||||||
|
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.
|
||||||
|
//
|
||||||
|
// 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 as Date).toISOString()
|
||||||
|
: param.value;
|
||||||
|
|
||||||
|
return encodeURIComponent(String(value));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
import { HttpParameterCodec } from '@angular/common/http';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom HttpParameterCodec
|
||||||
|
* Workaround for https://github.com/angular/angular/issues/18261
|
||||||
|
*/
|
||||||
|
export class CustomHttpParameterCodec implements HttpParameterCodec {
|
||||||
|
encodeKey(k: string): string {
|
||||||
|
return encodeURIComponent(k);
|
||||||
|
}
|
||||||
|
encodeValue(v: string): string {
|
||||||
|
return encodeURIComponent(v);
|
||||||
|
}
|
||||||
|
decodeKey(k: string): string {
|
||||||
|
return decodeURIComponent(k);
|
||||||
|
}
|
||||||
|
decodeValue(v: string): string {
|
||||||
|
return decodeURIComponent(v);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
export * from './api/api';
|
||||||
|
export * from './model/models';
|
||||||
|
export * from './variables';
|
||||||
|
export * from './configuration';
|
||||||
|
export * from './api.module';
|
||||||
|
export * from './param';
|
|
@ -0,0 +1,29 @@
|
||||||
|
/**
|
||||||
|
* Recettes - OpenAPI 3.0
|
||||||
|
* API recettes
|
||||||
|
*
|
||||||
|
* The version of the OpenAPI document: 1.0.0
|
||||||
|
* Contact: meutel@meutel.net
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
import { Quantity } from './quantity';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ingredient in receipe
|
||||||
|
*/
|
||||||
|
export interface Ingredient {
|
||||||
|
quantity?: Quantity;
|
||||||
|
/**
|
||||||
|
* Name of ingredient
|
||||||
|
*/
|
||||||
|
text?: string;
|
||||||
|
/**
|
||||||
|
* Link to ingredient parameter
|
||||||
|
*/
|
||||||
|
ref?: string;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
export * from './ingredient';
|
||||||
|
export * from './quantity';
|
||||||
|
export * from './receipe';
|
||||||
|
export * from './receipeReceipeYield';
|
||||||
|
export * from './recetteParam';
|
||||||
|
export * from './step';
|
|
@ -0,0 +1,21 @@
|
||||||
|
/**
|
||||||
|
* Recettes - OpenAPI 3.0
|
||||||
|
* API recettes
|
||||||
|
*
|
||||||
|
* The version of the OpenAPI document: 1.0.0
|
||||||
|
* Contact: meutel@meutel.net
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
export interface Quantity {
|
||||||
|
value: number;
|
||||||
|
/**
|
||||||
|
* Unit of quantity
|
||||||
|
*/
|
||||||
|
unit?: string;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
/**
|
||||||
|
* Recettes - OpenAPI 3.0
|
||||||
|
* API recettes
|
||||||
|
*
|
||||||
|
* The version of the OpenAPI document: 1.0.0
|
||||||
|
* Contact: meutel@meutel.net
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
import { Ingredient } from './ingredient';
|
||||||
|
import { ReceipeReceipeYield } from './receipeReceipeYield';
|
||||||
|
import { Step } from './step';
|
||||||
|
|
||||||
|
|
||||||
|
export interface Receipe {
|
||||||
|
/**
|
||||||
|
* Receipe unique id
|
||||||
|
*/
|
||||||
|
id: string;
|
||||||
|
/**
|
||||||
|
* Receipe name
|
||||||
|
*/
|
||||||
|
name: string;
|
||||||
|
/**
|
||||||
|
* Receipe description
|
||||||
|
*/
|
||||||
|
description?: string;
|
||||||
|
/**
|
||||||
|
* Cooking time
|
||||||
|
*/
|
||||||
|
cookTime?: string;
|
||||||
|
/**
|
||||||
|
* Preparation time
|
||||||
|
*/
|
||||||
|
prepTime?: string;
|
||||||
|
/**
|
||||||
|
* Receipe author/source
|
||||||
|
*/
|
||||||
|
author?: string;
|
||||||
|
ingredients: Array<Ingredient>;
|
||||||
|
steps: Array<Step>;
|
||||||
|
receipeYield?: ReceipeReceipeYield;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
/**
|
||||||
|
* Recettes - OpenAPI 3.0
|
||||||
|
* API recettes
|
||||||
|
*
|
||||||
|
* The version of the OpenAPI document: 1.0.0
|
||||||
|
* Contact: meutel@meutel.net
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
import { Quantity } from './quantity';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Quantity produced by receipe
|
||||||
|
*/
|
||||||
|
export interface ReceipeReceipeYield {
|
||||||
|
quantity: Quantity;
|
||||||
|
/**
|
||||||
|
* Production target
|
||||||
|
*/
|
||||||
|
of: string;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
/**
|
||||||
|
* Recettes - OpenAPI 3.0
|
||||||
|
* API recettes
|
||||||
|
*
|
||||||
|
* The version of the OpenAPI document: 1.0.0
|
||||||
|
* Contact: meutel@meutel.net
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
export interface RecetteParam {
|
||||||
|
/**
|
||||||
|
* Parameter unique id
|
||||||
|
*/
|
||||||
|
id: string;
|
||||||
|
/**
|
||||||
|
* Parameter name
|
||||||
|
*/
|
||||||
|
name: string;
|
||||||
|
/**
|
||||||
|
* Parameter type
|
||||||
|
*/
|
||||||
|
type: string;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
/**
|
||||||
|
* Recettes - OpenAPI 3.0
|
||||||
|
* API recettes
|
||||||
|
*
|
||||||
|
* The version of the OpenAPI document: 1.0.0
|
||||||
|
* Contact: meutel@meutel.net
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Step in receipe
|
||||||
|
*/
|
||||||
|
export interface Step {
|
||||||
|
/**
|
||||||
|
* position of step in receipe
|
||||||
|
*/
|
||||||
|
position?: number;
|
||||||
|
/**
|
||||||
|
* step instruction
|
||||||
|
*/
|
||||||
|
text?: string;
|
||||||
|
/**
|
||||||
|
* step hint
|
||||||
|
*/
|
||||||
|
hint?: string;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"$schema": "./node_modules/ng-packagr/ng-package.schema.json",
|
||||||
|
"lib": {
|
||||||
|
"entryFile": "index.ts"
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,34 @@
|
||||||
|
{
|
||||||
|
"name": "recettes-ng-client",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "OpenAPI client for recettes-ng-client",
|
||||||
|
"author": "OpenAPI-Generator Contributors",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/GIT_USER_ID/GIT_REPO_ID.git"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"openapi-client",
|
||||||
|
"openapi-generator"
|
||||||
|
],
|
||||||
|
"license": "Unlicense",
|
||||||
|
"scripts": {
|
||||||
|
"build": "ng-packagr -p ng-package.json"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@angular/core": "^14.0.5",
|
||||||
|
"rxjs": "^7.5.5"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@angular/common": "^14.0.5",
|
||||||
|
"@angular/compiler": "^14.0.5",
|
||||||
|
"@angular/compiler-cli": "^14.0.5",
|
||||||
|
"@angular/core": "^14.0.5",
|
||||||
|
"@angular/platform-browser": "^14.0.5",
|
||||||
|
"ng-packagr": "^14.0.2",
|
||||||
|
"reflect-metadata": "^0.1.3",
|
||||||
|
"rxjs": "^7.5.5",
|
||||||
|
"tsickle": "^0.46.3",
|
||||||
|
"typescript": ">=4.6.0 <=4.8.0",
|
||||||
|
"zone.js": "^0.11.5"
|
||||||
|
}}
|
|
@ -0,0 +1,69 @@
|
||||||
|
/**
|
||||||
|
* Standard parameter styles defined by OpenAPI spec
|
||||||
|
*/
|
||||||
|
export type StandardParamStyle =
|
||||||
|
| 'matrix'
|
||||||
|
| 'label'
|
||||||
|
| 'form'
|
||||||
|
| 'simple'
|
||||||
|
| 'spaceDelimited'
|
||||||
|
| 'pipeDelimited'
|
||||||
|
| 'deepObject'
|
||||||
|
;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The OpenAPI standard {@link StandardParamStyle}s may be extended by custom styles by the user.
|
||||||
|
*/
|
||||||
|
export type ParamStyle = StandardParamStyle | string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard parameter locations defined by OpenAPI spec
|
||||||
|
*/
|
||||||
|
export type ParamLocation = 'query' | 'header' | 'path' | 'cookie';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard types as defined in <a href="https://swagger.io/specification/#data-types">OpenAPI Specification: Data Types</a>
|
||||||
|
*/
|
||||||
|
export type StandardDataType =
|
||||||
|
| "integer"
|
||||||
|
| "number"
|
||||||
|
| "boolean"
|
||||||
|
| "string"
|
||||||
|
| "object"
|
||||||
|
| "array"
|
||||||
|
;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard {@link DataType}s plus your own types/classes.
|
||||||
|
*/
|
||||||
|
export type DataType = StandardDataType | string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard formats as defined in <a href="https://swagger.io/specification/#data-types">OpenAPI Specification: Data Types</a>
|
||||||
|
*/
|
||||||
|
export type StandardDataFormat =
|
||||||
|
| "int32"
|
||||||
|
| "int64"
|
||||||
|
| "float"
|
||||||
|
| "double"
|
||||||
|
| "byte"
|
||||||
|
| "binary"
|
||||||
|
| "date"
|
||||||
|
| "date-time"
|
||||||
|
| "password"
|
||||||
|
;
|
||||||
|
|
||||||
|
export type DataFormat = StandardDataFormat | string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The parameter to encode.
|
||||||
|
*/
|
||||||
|
export interface Param {
|
||||||
|
name: string;
|
||||||
|
value: unknown;
|
||||||
|
in: ParamLocation;
|
||||||
|
style: ParamStyle,
|
||||||
|
explode: boolean;
|
||||||
|
dataType: DataType;
|
||||||
|
dataFormat: DataFormat | undefined;
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"emitDecoratorMetadata": true,
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"noImplicitAny": false,
|
||||||
|
"suppressImplicitAnyIndexErrors": true,
|
||||||
|
"target": "es5",
|
||||||
|
"module": "commonjs",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"removeComments": true,
|
||||||
|
"sourceMap": true,
|
||||||
|
"outDir": "./dist",
|
||||||
|
"noLib": false,
|
||||||
|
"declaration": true,
|
||||||
|
"lib": [ "es6", "dom" ],
|
||||||
|
"typeRoots": [
|
||||||
|
"node_modules/@types"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"exclude": [
|
||||||
|
"node_modules",
|
||||||
|
"dist"
|
||||||
|
],
|
||||||
|
"filesGlob": [
|
||||||
|
"./model/*.ts",
|
||||||
|
"./api/*.ts"
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
import { InjectionToken } from '@angular/core';
|
||||||
|
|
||||||
|
export const BASE_PATH = new InjectionToken<string>('basePath');
|
||||||
|
export const COLLECTION_FORMATS = {
|
||||||
|
'csv': ',',
|
||||||
|
'tsv': ' ',
|
||||||
|
'ssv': ' ',
|
||||||
|
'pipes': '|'
|
||||||
|
}
|
|
@ -32,7 +32,8 @@
|
||||||
"styles": [
|
"styles": [
|
||||||
"src/styles.scss"
|
"src/styles.scss"
|
||||||
],
|
],
|
||||||
"scripts": []
|
"scripts": [],
|
||||||
|
"preserveSymlinks": true
|
||||||
},
|
},
|
||||||
"configurations": {
|
"configurations": {
|
||||||
"production": {
|
"production": {
|
||||||
|
@ -53,7 +54,13 @@
|
||||||
"development": {
|
"development": {
|
||||||
"optimization": false,
|
"optimization": false,
|
||||||
"extractLicenses": false,
|
"extractLicenses": false,
|
||||||
"sourceMap": true
|
"sourceMap": true,
|
||||||
|
"fileReplacements": [
|
||||||
|
{
|
||||||
|
"replace": "src/environments/environment.ts",
|
||||||
|
"with": "src/environments/environment.development.ts"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"defaultConfiguration": "production"
|
"defaultConfiguration": "production"
|
||||||
|
|
|
@ -2,7 +2,17 @@ import { ApplicationConfig } from '@angular/core';
|
||||||
import { provideRouter } from '@angular/router';
|
import { provideRouter } from '@angular/router';
|
||||||
|
|
||||||
import { routes } from './app.routes';
|
import { routes } from './app.routes';
|
||||||
|
import { provideHttpClient } from '@angular/common/http';
|
||||||
|
import { BASE_PATH } from 'recettes-ng-client';
|
||||||
|
import { environment } from '../environments/environment';
|
||||||
|
|
||||||
|
|
||||||
export const appConfig: ApplicationConfig = {
|
export const appConfig: ApplicationConfig = {
|
||||||
providers: [provideRouter(routes)]
|
providers: [
|
||||||
|
{
|
||||||
|
provide: BASE_PATH, useValue: environment.apiUrl
|
||||||
|
},
|
||||||
|
provideRouter(routes),
|
||||||
|
provideHttpClient()
|
||||||
|
]
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
import { NgModule } from '@angular/core';
|
||||||
|
import { ApiModule, Configuration } from 'recettes-ng-client';
|
||||||
|
import { AuthService } from './auth.service';
|
||||||
|
import { environment } from '../environments/environment';
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [ ApiModule ],
|
||||||
|
providers: [
|
||||||
|
{
|
||||||
|
provide: Configuration,
|
||||||
|
useFactory: (authService: AuthService) => new Configuration(
|
||||||
|
{
|
||||||
|
basePath: environment.apiUrl,
|
||||||
|
accessToken: authService.getAccessToken.bind(authService)
|
||||||
|
}
|
||||||
|
),
|
||||||
|
deps: [AuthService],
|
||||||
|
multi: false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
export class AppModule {}
|
|
@ -1,13 +1,13 @@
|
||||||
import { TestBed } from '@angular/core/testing';
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
import { ReceipesService } from './receipes.service';
|
import { AuthService } from './auth.service';
|
||||||
|
|
||||||
describe('ReceipesService', () => {
|
describe('AuthService', () => {
|
||||||
let service: ReceipesService;
|
let service: AuthService;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({});
|
TestBed.configureTestingModule({});
|
||||||
service = TestBed.inject(ReceipesService);
|
service = TestBed.inject(AuthService);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be created', () => {
|
it('should be created', () => {
|
|
@ -0,0 +1,13 @@
|
||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class AuthService {
|
||||||
|
|
||||||
|
constructor() { }
|
||||||
|
|
||||||
|
getAccessToken(): string {
|
||||||
|
return 'token'
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
<p>receipes-list works!</p>
|
<p>receipes-list works!</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li *ngFor="let r of receipes">
|
<li *ngFor="let r of receipes">
|
||||||
{{ r.title }}
|
{{ r.name }}
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
|
@ -1,22 +1,26 @@
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { CommonModule, NgFor } from '@angular/common';
|
import { CommonModule, NgFor } from '@angular/common';
|
||||||
import { ReceipesService } from '../receipes.service';
|
import { Receipe, ReceipeService } from 'recettes-ng-client';
|
||||||
|
import { AppModule } from '../app.module';
|
||||||
|
import { environment } from '../../environments/environment';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-receipes-list',
|
selector: 'app-receipes-list',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [CommonModule, NgFor],
|
imports: [CommonModule, AppModule, NgFor],
|
||||||
templateUrl: './receipes-list.component.html',
|
templateUrl: './receipes-list.component.html',
|
||||||
styleUrl: './receipes-list.component.scss'
|
styleUrl: './receipes-list.component.scss'
|
||||||
})
|
})
|
||||||
export class ReceipesListComponent implements OnInit {
|
export class ReceipesListComponent implements OnInit {
|
||||||
|
|
||||||
receipes: any[] = []
|
receipes: Receipe[] = []
|
||||||
|
|
||||||
constructor(private receipesService: ReceipesService) {}
|
constructor(private receipeService: ReceipeService) {
|
||||||
|
console.log(environment.apiUrl)
|
||||||
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.receipesService.allReceipes()
|
this.receipeService.findReceipes()
|
||||||
.subscribe(list => this.receipes = list)
|
.subscribe(list => this.receipes = list)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
import { Injectable } from '@angular/core';import { Observable, of } from 'rxjs';
|
|
||||||
|
|
||||||
@Injectable({
|
|
||||||
providedIn: 'root'
|
|
||||||
})
|
|
||||||
export class ReceipesService {
|
|
||||||
|
|
||||||
private RECEIPES = [
|
|
||||||
{ title: 'pates carbo', id: 1 },
|
|
||||||
{ title: 'tartes aux pommes', id: 2 }
|
|
||||||
]
|
|
||||||
|
|
||||||
constructor() { }
|
|
||||||
|
|
||||||
allReceipes(): Observable<any[]> {
|
|
||||||
return of(this.RECEIPES)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
export const environment = {
|
||||||
|
apiUrl: 'http://localhost:8080'
|
||||||
|
};
|
|
@ -0,0 +1,3 @@
|
||||||
|
export const environment = {
|
||||||
|
apiUrl: 'https://recettes.meutel.net'
|
||||||
|
};
|
Loading…
Reference in New Issue