Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(schematic-sdk): support the multi tag in SDK's APIs #1942

Merged
merged 2 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions migration-guides/11.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

- `prepareOptions` method has been removed from `ApiClient`. `getRequestOptions` should be used instead.
- To support `JSON` specification format and to remove the reference to the outdated `Swagger` format name, the file containing the current specification used to generate the SDK will be stored in a file `open-api.yaml` or `open-api.json` instead of `swagger-api.yaml`.
- To avoid interface name conflicts in case of an API with multiple tags (See issue [#855](https://github.com/AmadeusITGroup/otter/issues/855)), the API parameter object interface named with the pattern `<api-function-name>RequestData` will now be named with the pattern `<api-function-name><api-name>RequestData`.
- The same renaming is applied to `enum` types in request parameters. It changes from `<api-function-name><parameter-name>Enum` to `<api-name><api-function-name><parameter-name>Enum`.

## @o3r/schematics

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,20 @@ import { Api, ApiClient, ApiTypes, computePiiParameterTokens, isJsonMimeType, Re
{{#operation}}
{{#allParams}}
{{#isEnum}}
export type {{#uppercaseFirst}}{{nickname}}{{/uppercaseFirst}}{{#uppercaseFirst}}{{paramName}}{{/uppercaseFirst}}Enum = {{#trimPipe}}{{#allowableValues}}{{#values}}'{{.}}' | {{/values}}{{/allowableValues}}{{/trimPipe}};
/** Enum {{paramName}} used in the {{classname}}'s {{nickname}} function parameter */
export type {{classname}}{{#uppercaseFirst}}{{nickname}}{{/uppercaseFirst}}{{#uppercaseFirst}}{{paramName}}{{/uppercaseFirst}}Enum = {{#trimPipe}}{{#allowableValues}}{{#values}}'{{.}}' | {{/values}}{{/allowableValues}}{{/trimPipe}};

{{/isEnum}}
{{/allParams}}
{{/operation}}
{{#operation}}
export interface {{#uppercaseFirst}}{{nickname}}{{/uppercaseFirst}}RequestData {
/** Parameters object to {{classname}}'s {{nickname}} function */
export interface {{classname}}{{#uppercaseFirst}}{{nickname}}{{/uppercaseFirst}}RequestData {
{{#allParams}}
/** {{#description}}{{{description}}}{{/description}}{{^description}}{{#isArray}}List of {{#plurialize}}{{#noArrayInType}}{{{dataType}}}{{/noArrayInType}}{{/plurialize}}{{/isArray}}{{/description}} */
'{{baseName}}'{{^required}}?{{/required}}{{#required}}{{#defaultValue}}?{{/defaultValue}}{{/required}}: {{#isEnum}}{{#uppercaseFirst}}{{nickname}}{{/uppercaseFirst}}{{#uppercaseFirst}}{{paramName}}{{/uppercaseFirst}}Enum{{#isArray}}[]{{/isArray}}{{/isEnum}}{{^isEnum}}{{#isBodyParam}}{{{baseType}}}{{#isArray}}[]{{/isArray}}{{/isBodyParam}}{{^isBodyParam}}{{{dataType}}}{{/isBodyParam}}{{/isEnum}};
'{{baseName}}'{{^required}}?{{/required}}{{#required}}{{#defaultValue}}?{{/defaultValue}}{{/required}}: {{#isEnum}}{{classname}}{{#uppercaseFirst}}{{nickname}}{{/uppercaseFirst}}{{#uppercaseFirst}}{{paramName}}{{/uppercaseFirst}}Enum{{#isArray}}[]{{/isArray}}{{/isEnum}}{{^isEnum}}{{#isBodyParam}}{{{baseType}}}{{#isArray}}[]{{/isArray}}{{/isBodyParam}}{{^isBodyParam}}{{{dataType}}}{{/isBodyParam}}{{/isEnum}};
{{/allParams}}
}
{{/operation}}
{{#operation}}
/**
* @Deprecated, please use {{#uppercaseFirst}}{{nickname}}{{/uppercaseFirst}}RequestData
*/
export interface {{#uppercaseFirst}}{{nickname}}{{/uppercaseFirst}} extends {{#uppercaseFirst}}{{nickname}}{{/uppercaseFirst}}RequestData {}

{{/operation}}
{{#description}}
/**
Expand Down Expand Up @@ -68,13 +64,13 @@ export class {{classname}} implements Api {
* @param data Data to provide to the API call
* @param metadata Metadata to pass to the API call
*/
public async {{nickname}}(data: {{#uppercaseFirst}}{{nickname}}{{/uppercaseFirst}}RequestData, metadata?: RequestMetadata<{{#consumes}}'{{mediaType}}'{{^-last}} | {{/-last}}{{/consumes}}{{^consumes}}string{{/consumes}}, {{#produces}}'{{mediaType}}'{{^-last}} | {{/-last}}{{/produces}}{{^produces}}string{{/produces}}>): Promise<{{#vendorExtensions}}{{#responses2xxReturnTypes}}{{.}}{{^-last}} | {{/-last}}{{/responses2xxReturnTypes}}{{^responses2xxReturnTypes}}never{{/responses2xxReturnTypes}}{{/vendorExtensions}}> {
public async {{nickname}}(data: {{classname}}{{#uppercaseFirst}}{{nickname}}{{/uppercaseFirst}}RequestData, metadata?: RequestMetadata<{{#consumes}}'{{mediaType}}'{{^-last}} | {{/-last}}{{/consumes}}{{^consumes}}string{{/consumes}}, {{#produces}}'{{mediaType}}'{{^-last}} | {{/-last}}{{/produces}}{{^produces}}string{{/produces}}>): Promise<{{#vendorExtensions}}{{#responses2xxReturnTypes}}{{.}}{{^-last}} | {{/-last}}{{/responses2xxReturnTypes}}{{^responses2xxReturnTypes}}never{{/responses2xxReturnTypes}}{{/vendorExtensions}}> {
{{#allParams}}
{{#defaultValue}}
data['{{baseName}}'] = data['{{baseName}}'] !== undefined ? data['{{baseName}}'] : {{#isString}}'{{/isString}}{{defaultValue}}{{#isString}}'{{/isString}};
{{/defaultValue}}
{{/allParams}}
const queryParams = this.client.extractQueryParams<{{#uppercaseFirst}}{{nickname}}{{/uppercaseFirst}}RequestData>(data, [{{#trimComma}}{{#queryParams}}'{{baseName}}', {{/queryParams}}{{/trimComma}}]{{^queryParams}} as never[]{{/queryParams}});
const queryParams = this.client.extractQueryParams<{{classname}}{{#uppercaseFirst}}{{nickname}}{{/uppercaseFirst}}RequestData>(data, [{{#trimComma}}{{#queryParams}}'{{baseName}}', {{/queryParams}}{{/trimComma}}]{{^queryParams}} as never[]{{/queryParams}});
const metadataHeaderAccept = metadata?.headerAccept || '{{#headerJsonMimeType}}{{#produces}}{{mediaType}}{{^-last}}, {{/-last}}{{/produces}}{{/headerJsonMimeType}}';
const headers: { [key: string]: string | undefined } = {
{{#trimComma}} 'Content-Type': metadata?.headerContentType || '{{#headerJsonMimeType}}{{#consumes}}{{mediaType}}{{^-last}}, {{/-last}}{{/consumes}}{{/headerJsonMimeType}}',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{#apiInfo}}
{{#apis}}
{{#operations}}
export type { {{#operation}}{{#uppercaseFirst}}{{nickname}}{{/uppercaseFirst}}RequestData{{^-last}}, {{/-last}}{{/operation}} } from './{{#apiFolderName}}{{classname}}{{/apiFolderName}}/index';
export type { {{#operation}}{{classname}}{{#uppercaseFirst}}{{nickname}}{{/uppercaseFirst}}RequestData{{^-last}}, {{/-last}}{{/operation}} } from './{{#apiFolderName}}{{classname}}{{/apiFolderName}}/index';
export { {{classname}} } from './{{#apiFolderName}}{{classname}}{{/apiFolderName}}/index';
{{/operations}}
{{/apis}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{{#noEmptyExport}}
{{#apis}}
{{#operations}}
export type { {{#trimComma}}{{#operation}}{{#allParams}}{{#isEnum}}{{#uppercaseFirst}}{{nickname}}{{/uppercaseFirst}}{{#uppercaseFirst}}{{paramName}}{{/uppercaseFirst}}Enum, {{/isEnum}}{{/allParams}}{{/operation}}{{/trimComma}} } from './{{#apiFolderName}}{{classname}}{{/apiFolderName}}/index';
export type { {{#trimComma}}{{#operation}}{{#allParams}}{{#isEnum}}{{classname}}{{#uppercaseFirst}}{{nickname}}{{/uppercaseFirst}}{{#uppercaseFirst}}{{paramName}}{{/uppercaseFirst}}Enum, {{/isEnum}}{{/allParams}}{{/operation}}{{/trimComma}} } from './{{#apiFolderName}}{{classname}}{{/apiFolderName}}/index';
{{/operations}}
{{/apis}}
{{/noEmptyExport}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{{/imports}}

{{#operations}}
import { {{#uppercaseFirst}}{{classname}}{{/uppercaseFirst}}{{#operation}}, {{#uppercaseFirst}}{{nickname}}{{/uppercaseFirst}}RequestData{{/operation}} } from './{{#kebabCase}}{{classname}}{{/kebabCase}}';
import { {{#uppercaseFirst}}{{classname}}{{/uppercaseFirst}}{{#operation}}, {{classname}}{{#uppercaseFirst}}{{nickname}}{{/uppercaseFirst}}RequestData{{/operation}} } from './{{#kebabCase}}{{classname}}{{/kebabCase}}';

{{#description}}
/**
Expand All @@ -17,7 +17,7 @@ export class {{#uppercaseFirst}}{{classname}}{{/uppercaseFirst}}Fixture implemen
{{#operation}} /**
* Fixture associated to function {{nickname}}
*/
public {{nickname}}: jest.Mock<Promise<{{#vendorExtensions}}{{#responses2xxReturnTypes}}{{.}}{{^-last}} | {{/-last}}{{/responses2xxReturnTypes}}{{^responses2xxReturnTypes}}never{{/responses2xxReturnTypes}}{{/vendorExtensions}}>, [{{#uppercaseFirst}}{{nickname}}{{/uppercaseFirst}}RequestData]> = jest.fn();
public {{nickname}}: jest.Mock<Promise<{{#vendorExtensions}}{{#responses2xxReturnTypes}}{{.}}{{^-last}} | {{/-last}}{{/responses2xxReturnTypes}}{{^responses2xxReturnTypes}}never{{/responses2xxReturnTypes}}{{/vendorExtensions}}>, [{{classname}}{{#uppercaseFirst}}{{nickname}}{{/uppercaseFirst}}RequestData]> = jest.fn();
{{/operation}}
}
{{/operations}}{{/noUnusedImport}}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
{{#apiInfo}}
{{#apis}}
{{#operations}}
export type { {{#operation}}{{#uppercaseFirst}}{{nickname}}{{/uppercaseFirst}}RequestData{{^-last}}, {{/-last}}{{/operation}} } from './{{#apiFolderName}}{{classname}}{{/apiFolderName}}/index';
{{/operations}}
{{#operations}}
export type { {{#operation}}{{#uppercaseFirst}}{{nickname}}{{/uppercaseFirst}}{{^-last}}, {{/-last}}{{/operation}} } from './{{#apiFolderName}}{{classname}}{{/apiFolderName}}/index';
export type { {{#operation}}{{classname}}{{#uppercaseFirst}}{{nickname}}{{/uppercaseFirst}}RequestData{{^-last}}, {{/-last}}{{/operation}} } from './{{#apiFolderName}}{{classname}}{{/apiFolderName}}/index';
{{/operations}}
{{/apis}}
{{/apiInfo}}
Loading