OpenAPITools / OpenAPITools/openapi-generator

[BUG] Omitted read-only fields are snake-case, although model fields are camel-case

Open
#21,091 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.