Enum list issue
Closed this issue · 0 comments
sebplorenz commented
Hi,
there seems to be an issue when generating an enum that is a used in a list property of an object.
The following spec:
openapi: 3.0.2
info:
title: Test Spec
version: '0'
paths: { }
components:
schemas:
Person:
type: object
properties:
mood:
type: array
items:
type: string
enum:
- HAPPY
- CREATIVE
- CHALLANGED
- WORRIED
- SUICIDAL
generates this enum:
public enum Mood {
HAPPY("HAPPY"),
CREATIVE("CREATIVE"),
CHALLANGED("CHALLANGED"),
WORRIED("WORRIED"),
SUICIDAL("SUICIDAL");
public static final java.util.List<java.lang.String> HAPPY_VALUE = "HAPPY";
public static final java.util.List<java.lang.String> CREATIVE_VALUE = "CREATIVE";
public static final java.util.List<java.lang.String> CHALLANGED_VALUE = "CHALLANGED";
public static final java.util.List<java.lang.String> WORRIED_VALUE = "WORRIED";
public static final java.util.List<java.lang.String> SUICIDAL_VALUE = "SUICIDAL";
private final java.util.List<java.lang.String> value;
private Mood(java.util.List<java.lang.String> value) {
this.value = value;
}
@com.fasterxml.jackson.annotation.JsonCreator
public static Mood toEnum(java.util.List<java.lang.String> value) {
return toOptional(value).orElseThrow(() -> new IllegalArgumentException("Unknown value '" + value + "'."));
}
public static java.util.Optional<Mood> toOptional(java.util.List<java.lang.String> value) {
return java.util.Arrays
.stream(values())
.filter(e -> e.value.equals(value))
.findAny();
}
@com.fasterxml.jackson.annotation.JsonValue
public java.util.List<java.lang.String> getValue() {
return value;
}
}