OpenAPITools / OpenAPITools/openapi-generator
[BUG] Omitted read-only fields are snake-case, although model fields are camel-case
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
openapi-genarator generates correctly the TS representation of a model I have defined in DRF and exposed using DRF-spectacular:
export interface Mission {
* @type {string}
* @memberof Mission
*/
readonly id: string;
/**
*
* @type {string}
* @memberof Mission
*/
name: string;
/**
*
* @type {string}
* @memberof Mission
*/
description: string;
/**
*
* @type {string}
* @memberof Mission
*/
email?: string;
/**
*
* @type {number}
* @memberof Mission
*/
readonly user: number;
/**
*
* @type {Date}
* @memberof Mission
*/
readonly created: Date;
/**
*
* @type {number}
* @memberof Mission
*/
readonly instancesCount: number;
}
However, fields which were marked read-only in DRF are added to one of the API requests, without camelcase, but in snakecase:
Herebelow instances_count is snakecase, where it is camelcase in the model above:
export interface CatalogMissionsCreateRequest {
mission: Omit<Mission, 'id'|'user'|'created'|'instances_count'>;
format?: CatalogMissionsCreateFormatEnum;
}
openapi-generator version
"@openapitools/openapi-generator-cli": "^2.17.0"
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the generated TypeScript interfaces from the DRF model exposed through DRF-spectacular, comparing Mission with CatalogMissionsCreateRequest. Start by tracing the TypeScript generator's handling of read-only fields and verify that the generated Omit keys match the model's camel-case names; done means the request type uses the same names as Mission.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, python, typescript
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100