openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

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

Open Sqh3rd opened this issue 1 year ago • 1 comments

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 avatar Aug 23 '24 08:08 Sqh3rd

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 :)

Sqh3rd avatar Aug 26 '24 06:08 Sqh3rd