Skip to content

Commit

Permalink
fix(schematic-sdk): including breaking change to support the multi ta…
Browse files Browse the repository at this point in the history
…g API

[Bug]: Multi tagged APIs not supported #855
  • Loading branch information
kpanot committed Jul 2, 2024
1 parent f33cdc2 commit 24d02bc
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 17 deletions.
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 conflict in case of 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 `<api-function-name><api-name>RequestData`.
- The same renaming is applied to the `enum` types part of 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}};
{{/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 @@ -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}}

0 comments on commit 24d02bc

Please sign in to comment.