Reputation: 3598
I am using Swagger codegen 3.0.8 to generate Java files. Part of the yaml spec is
PrepositionalPhrase:
type: object
required:
- preposition
- objects
properties:
preposition:
description: The preposition
type: string
enum:
- of
- on
- or
(with more values stripped for conciseness). The generated enum is
public enum PrepositionEnum {
OF("of"),
TRUE("true"),
OR("or")
}
For some reason, it appears that on
is being mapped to true
. I can see that happening in some config parser, where "on" would logically mean "true", but that does not work for code generation.
The command line I am using to generate is
swagger-codegen generate \
-i api.yaml \
-l java \
--api-package com.example \
--artifact-version 1.2.0 \
--artifact-id example \
--group-id com.example \
--model-package com.example.model
Is there some way to prevent this from happening?
Upvotes: 1
Views: 459
Reputation: 10681
According to this ticket swagger-codegen/issues/2559, it's rather a YAML format feature, which seems to be right:
Language Independent Scalar types: { ~, null } : Null (no value). [ 1234, 0x4D2, 02333 ] : [ Decimal int, Hexadecimal int, Octal int ] [ 1_230.15, 12.3015e+02 ]: [ Fixed float, Exponential float ] [ .inf, -.Inf, .NAN ] : [ Infinity (float), Negative, Not a number ] { Y, true, Yes, ON } : Boolean true { n, FALSE, No, off } : Boolean false
Apparently the workaround is to quote the values in the YAML file.
Upvotes: 3