stoicflame / enunciate-openapi

OpenAPI3 module for Enunciate
Apache License 2.0
10 stars 10 forks source link

duplicated mapping key "type" by rendering Map of Arrays #37

Closed selimok closed 3 years ago

selimok commented 3 years ago

Hi,

I just discovered a openapi rendering problem. When I started swagger ui I saw "duplicated mapping key" error.

I have this property in one of my classes:

LinkedHashMap<String, LinkedHashSet<String>> tags;

This will be rendered by openapi plugin as:

"tags":
  description: "The list of tags and its values"
  type: object
  additionalProperties:
    type: string
  type: array
  items:
    type: string

While the swagger plugin generates this:

"tags"
  readOnly: false
  description: "The list of tags and its values"
  type: "object"
  additionalProperties:
    type: "array"
    items:
      type: "string"

I think the problem lies somewhere at Line 71 of DataTypeReferenceRenderer: https://github.com/stoicflame/enunciate-openapi/blame/6ffbce9cbced9dcd64b0b3d04f03d9d030e4e64f/src/main/java/dk/jyskebank/tools/enunciate/modules/openapi/DataTypeReferenceRenderer.java#L71

The "containers" has the value {map, array}. The implementation tries to render both as siblings instead of parent-child.

I don't know whether this behaviour is correct in other use cases but in my case it is incorrect.

Thanks.

Kind Regards Selim

stoicflame commented 3 years ago

38 merged.

selimok commented 3 years ago

Hi @stoicflame, Thank you very much for your quick merge :) When could we expect a release version which contains this fix ?

stoicflame commented 3 years ago

@jskovjyskebankdk can you provide some direction on how to publish this?

I tried gradlew publishPlugins but that didn't seem to work.

jskov-jyskebank-dk commented 3 years ago

Hi Ryan,

I imagine it is because it still tries to publish in Jyske Bank's namespace on MavenCentral.

I pushed some changes to remove references to the Jyske Bank build system.

And I think you need to change:

group 'dk.jyskebank.tooling.enunciate'

in build.gradle to your namespace (com.webcohesion.enunciate).

Then './gradlew dist' will generate the publishable artifacts in the dist folder.

That is all I have ever done; then uploaded manually via the web page.

(the publishPlugins task is only for publishing a Gradle plugin to their custom repository, not general artifacts to MavenCentral publish operation)

There has been a recent discussions about publishing with Gradle at https://old.reddit.com/r/java/comments/lk81xt/new_gradle_plugin_for_publishing_to_nexus_that/

But you might be best off by making a Maven file for the project.

Hope that helps. I do not have time to dive further into it.

Cheers, Jesper