Open noamk-hl opened 1 year ago
When a property uses allof for common configuration (such as enum values) and a default, the default isn't set in the model.
allof
default
What I get
'fruitType'?: FruitEnum;
Expected:
'fruitType'?: FruitEnum = FruitEnum.Apple;
6.6.0
openapi: "3.0.0" info: version: "1.0.0" title: "Test default enum value" paths: /eat: post: requestBody: content: application/json: schema: type: "object" properties: fruit_type: allOf: - $ref: '#/components/schemas/FruitEnum' default: "apple" responses: 200: description: "Yummy" components: schemas: FruitEnum: type: "string" enum: [ "melon", "apple" ]
This schema is based on schemas generated by drf-spectacular.
By the way, changing to the following does work:
fruit_type: allOf: - $ref: '#/components/schemas/FruitEnum' type: "string" default: "apple"
openapi-generator-cli generate -g typescript-node -i schema.yaml
Generate the client code.
The same bug occurs in other typescript generators.
I am on version 7.3.0 and am seeing similar behaviour. Default values don't appear to be added for fields of any type.
Bug Report Checklist
Description
When a property uses
allof
for common configuration (such as enum values) and adefault
, thedefault
isn't set in the model.What I get
Expected:
openapi-generator version
6.6.0
OpenAPI declaration file content or url
This schema is based on schemas generated by drf-spectacular.
By the way, changing to the following does work:
Generation Details
Steps to reproduce
Generate the client code.
Related issues/PRs
12634 is similar but not the same