OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.29k stars 6.44k forks source link

[BUG][typescript-angular] PropertyNames on dictionaries are ignored #19433

Open Sqh3rd opened 3 weeks ago

Sqh3rd commented 3 weeks ago

Description

If an object has a property that specifies additionalProperties and propertyNames then propertyNames is not taken into account when generating the interface.

openapi-generator version

7.8.0

OpenAPI declaration file content or url

components:
  schema:
    SomeDTO:
      map:
        type: object
        additionalProperties:
          type: array
          items:
            $ref: '#/components/schemas/OtherDTO'
        propertyNames:
          type: string
          enum:
          - FOO
          - BAR

Generation Details

Generated using: openapi-generator-maven-plugin

Configuration:

<typeMappings>
  <typeMapping>DateTime=string</typeMapping>
</typeMappings>

<configOptions>
  <ngVersion>17.3.11</ngVersion>
</configOptions>

Steps to reproduce

Run the generation and check the generated interface

expected output:

interface SomeDTO {
  map: {
    foo: Array<OtherDTO>;
    bar: Array<OtherDTO>;
    [key: string]: Array<OtherDTO>;
  }
}

actual output:

interface SomeDTO {
  map: { [key: string]: Array<OtherDTO>; }
}
Sqh3rd commented 2 weeks ago

Looking at it, I miss-labeled it, since it'd make more sense to see this as an enhancement. Also I'll be working on a PR for this feature :)