Skip to content

String/Boolean map using additionalProperties is not generated #191

@JFCote

Description

@JFCote
Description

I have a simple object declared like this:

StringBooleanMap:
      additionalProperties:
          type: boolean

It was used in another model:

  GetFrontEndPermissionsResponse:
    type: object
    required:
      - meta
    properties:
      meta:
        $ref: "#/definitions/ResponseMeta"
      data:
        $ref: "#/definitions/StringBooleanMap"

With swagger-codegen, it was simply generated and used in the models needing it. It was looking like that when used in a model:

@JsonProperty("data")
  private StringBooleanMap data = null;

With openapi-generator, it is not generated at all. Instead, it simply generate a "map" with no type.

@JsonProperty("data")
  private Map data = null;

This is a very bad regression since we cannot validate that the map really is a String/Boolean, we lose type safety.

openapi-generator version

Latest master

Command line used for generation

java -jar openapi-generator-cli.jar generate -i swagger.yaml --generator-name java-play-framework -o generatedServer -DhideGenerationTimestamp=true

Steps to reproduce

Just run the above command line and make sure you have and object using the StringBooleanMap object in one of its property.

Related issues/PRs

I think it is related to #185

Suggest a fix/enhancement

I think if we don't want to lose all the current swagger-codegen users that would want to switch, we need to generate stuff that was previously generated and it just make sense. If I create a model and that this model is referenced somewhere else, we should generate it "as is". Converting it to "basic type" is a very dangerous assumption that do not follow the spec in my opinion. And as I said earlier, this break type safety when dealing with collection (Map in this case)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions