Skip to content

JsonProperty not getting picked up by yaml generation for Enum #471

@ccorcoran-nydig

Description

@ccorcoran-nydig

Task List

  • [ X ] Steps to reproduce provided
  • [ N/A] Stacktrace (if present) provided
  • [ N/A] Example that reproduces the problem uploaded to Github
  • [ X ] Full description of the issue provided (see below)

Steps to Reproduce

  1. Create Java Enum Class with JsonProperty

import com.fasterxml.jackson.annotation.JsonProperty;

public enum CurrencyPair2 {
    @JsonProperty("CAD-USD") CADUSD("CAD", "USD");
    private final String baseCurrency;
    private final String quoteCurrency;

    CurrencyPair2(String baseCurrency, String quoteCurrency) {
        this.baseCurrency = baseCurrency;
        this.quoteCurrency = quoteCurrency;
    }

    public String getBaseCurrency() {
        return baseCurrency;
    }

    public String getQuoteCurrency() {
        return quoteCurrency;
    }

}

  1. Reference class in response object/request params
  2. Build OpenApi:

annotationProcessor("io.micronaut.openapi:micronaut-openapi")
...
implementation("io.swagger.core.v3:swagger-annotations:2.1.6")
...

tasks.withType(JavaCompile) {
options.fork = true
options.forkOptions.jvmArgs << '-Dmicronaut.openapi.views.spec=rapidoc.enabled=true,swagger-ui.enabled=true,swagger-ui.theme=flattop'
}

  1. Check Swagger output

Expected Behaviour

Enum values should be CAD-USD and serialization should convert appropriately

CurrencyPair2:
      type: string
      enum:
      - CAD-USD

Actual Behaviour

Serialization converts on ingress and egress appropriately but enum values are CADUSD in the swagger schema

CurrencyPair2:
      type: string
      enum:
      - CADUSD

Tell us what happens instead

Environment Information

  • Operating System: MavOS Mojave version 10.14.6
  • Micronaut Version: 1.3.4
  • JDK Version:
  • OPENAPI_VERSION=2.0.10

Example Application

  • TODO: link to github repository with example that reproduces the issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions