Skip to content

Commit

Permalink
In the OpenAPI v3 spec, the requestBody does not have a name. By de…
Browse files Browse the repository at this point in the history
…fault, it will be passed into the generated function as `requestBody`. Accept the commonly used `x-body-name` property in the operation schema to override this name. ferdikoomen#2011
  • Loading branch information
Gerson Goulart committed Jan 29, 2024
1 parent efa80da commit d25a969
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/openApi/v3/interfaces/OpenApiRequestBody.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ export interface OpenApiRequestBody extends OpenApiReference {
content: Dictionary<OpenApiMediaType>;
required?: boolean;
nullable?: boolean;
'x-body-name'?: string;
}
4 changes: 2 additions & 2 deletions src/openApi/v3/parser/getOperationRequestBody.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ export const getOperationRequestBody = (openApi: OpenApi, body: OpenApiRequestBo
const requestBody: OperationParameter = {
in: 'body',
export: 'interface',
prop: 'requestBody',
name: 'requestBody',
prop: body['x-body-name'] ?? 'requestBody',
name: body['x-body-name'] ?? 'requestBody',
type: 'any',
base: 'any',
template: null,
Expand Down
1 change: 0 additions & 1 deletion src/utils/writeClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import { writeClientServices } from './writeClientServices';
* @param exportServices Generate services
* @param exportModels Generate models
* @param exportSchemas Generate schemas
* @param exportSchemas Generate schemas
* @param indent Indentation options (4, 2 or tab)
* @param postfixServices Service name postfix
* @param postfixModels Model name postfix
Expand Down

0 comments on commit d25a969

Please sign in to comment.