Skip to content

[BUG][TYPESCRIPT] properties and required in DTO for yaml file all props becomes optional #22354

@MaikeldeWerd

Description

@MaikeldeWerd

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
Description

When generating the openapi files with the new v7.17.0 we are getting the results of having required fields set to optional.

What happens is that when we're having the uuid, it is required in the code with the previous update. Now when having both properties and required it sets the uuid to optional. When removing the properties it is required again.

openapi-generator version

v7.17.0

OpenAPI declaration file content or url

YAML:

openapi: 3.0.0
info:
  title: title
  version: 1.0.0
components:
  parameters:
    PATH-test:
      name: uuid
      in: path
      required: true
      schema:
        type: string
  schemas:
    TestExampleDto:
      type: object
      properties:
        uuid:
          type: string
    TestDto:
      type: object
      properties:
        comment:
          type: string
      allOf:
        - $ref: "#/components/schemas/TestExampleDto"
      required:
        - uuid

security:
    - bearerAuth: [ ]

paths:
  /api/test/{uuid}:
    get:
      parameters:
        - $ref: "#/components/parameters/PATH-test"
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TestDto"

openapitools.json:

{
    "$schema": "./node_modules/@openapitools/openapi-generator-cli/config.schema.json",
    "spaces": 4,
    "generator-cli": {
        "version": "7.17.0",
        "generators": {
            "example-test-service": {
                "additionalProperties": {
                    "stringEnums": true
                },
                "generatorName": "typescript-fetch",
                "inputSpec": ".openapi/DDNEI/example-test-service",
                "output": "src/js/types/openapi/example-test-service"
            }
        }
    }
}

Generation Details

Command:
openapi-generator-cli --openapitools 'openapitools.json' generate --generator-key 'example-test-service'

Steps to reproduce

Implement the code and run the command we've provided

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions