Skip to content

[BUG] Read-only fields are broken: 'Omit' uses snake-case attributes, whereas model uses camel-case #1181

@mmelcot

Description

@mmelcot

I have generated a React/TS client with openapi-generator.
The API is served by Django and Django REST Framework.

Django==4.2.6
drf-spectacular==0.28.0
djangorestframework==3.16.1

and

"@openapitools/openapi-generator-cli": "2.31.0",

I have noticed a bug in the api code generation:
The request definitions add a list of Omitted fields (which are the ones noted as read_only on the Django REST framework side).
However those fields are incorrectly written in snake-case in the Omit section.
Although they are correctly written in camel-case in the model definition.

Hence, the fields are not omitted, and the client complain that it doesn't find them when one try to use that request.

For instance, herebelow, the SingleCar field of the Mission model, is omitted as single_car (not SingleCar):

export interface CatalogMissionsCreateRequest {
    mission: Omit<Mission, 'id'|'single_car'>;
    format?: CatalogMissionsCreateFormatEnum;
}


export interface Mission {
    /**
     * 
     * @type {string}
     * @memberof Mission
     */
    readonly id: string;
	
    /**
     * 
     * @type {string}
     * @memberof Mission
     */
    name: string;
  
    /**
     * 
     * @type {Car}
     * @memberof Mission
     */
    readonly singleCar: Car;
}

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions