OpenAPIDTO Generator
Paste an OpenAPI 3 spec — JSON or YAML — and get Java records or classes with Jackson annotations, enums and java.time mapping.
In-browser & private
OpenAPI spec (JSON or YAML)
Ctrl + Enter to generate
Java
Paste a spec on the left, or press Sample.
Types —
Fields —
Size 0 B
How the types are chosen
An OpenAPI schema carries more type information than raw JSON does, so this maps rather than guesses — but a few of those mappings are judgement calls, and they are worth stating.
numberbecomesBigDecimalunless the spec saysfloatordouble. Prices and quantities turn up in almost every real spec, and binary floating point is the wrong default for either.- Dates follow the format.
datebecomesLocalDate,date-timebecomesOffsetDateTime— notLocalDateTime, because an API timestamp carries an offset and dropping it loses information. allOfis flattened. It is how OpenAPI expresses composition, and Java has no structural intersection type — so the members are merged into one flat DTO.- Enums keep their wire value. A value like
in progresscannot be a Java constant, so the constant isIN_PROGRESSand the original string is retained for Jackson to serialise. - Names are converted, not renamed.
total_amountbecomestotalAmountand carries@JsonProperty("total_amount")so it still binds. Java keywords get a suffix — a field calledclasswould not compile.