eclipse / microprofile-open-api

Microprofile open api
Apache License 2.0
131 stars 82 forks source link

a boolean type property named empty is auto generated in openapi spec file when schema extends HashMap #450

Closed LinghaoYu closed 3 years ago

LinghaoYu commented 3 years ago

We have a model defined as

@Schema(name = "MapResource", description = "A single map resource", requiredProperties = {})
public class MapResource extends HashMap<String, List<MapResourceEntry>> {

    public MapResource() {
        // Empty MapResource constructor
    }
}

In the generated openapi spec file, it becomes

components:
  schemas:
    MapResource:
      type: object
      properties:
        empty:
          type: boolean
      description: A single map resource
      additionalProperties:
        type: array
        items:
          $ref: '#/components/schemas/MapResource.MapResourceEntry'

How to get rid of this empty property? Swagger core has the same issue https://github.com/swagger-api/swagger-core/issues/3535# but their workaround cannot be applied to microprofile.

MikeEdgar commented 3 years ago

@LinghaoYu - see if adding this field to your class works:

@Schema(hidden = true)
boolean empty;
LinghaoYu commented 3 years ago

Hi @MikeEdgar Thanks, it worked!