OpenAPI to Spring Controller Generator
Paste an OpenAPI 3 spec — JSON or YAML — and get Spring Boot controllers, one per tag, with mappings, parameters and return types.
In-browser & private
OpenAPI spec (JSON or YAML)
Ctrl + Enter to generate
Java
Paste a spec on the left, or press Sample.
Controllers —
Endpoints —
Size 0 B
What it generates, and why
- One controller per tag. A spec's tags are already the author's grouping of the API, so following them produces the file layout a person would have chosen by hand.
- Optional query parameters say so. A parameter that is not
requiredis emitted as@RequestParam(required = false)— without it Spring returns 400 whenever the caller leaves it out, which is the opposite of what the spec says. - Path variables are bound by name.
{orderId}becomes@PathVariable("orderId")when the Java name differs, so it keeps working after compilation without-parameters. - Interface mode puts the mappings in the interface. That keeps the annotations in step with the spec while your implementation stays yours — regenerate the interface, and the compiler tells you what changed.
- Bodies are typed. The request body schema resolves to the same DTO name the DTO generator produces, so the two outputs fit together.
Frequently asked questions
- Is my spec uploaded anywhere?
- No. The spec is parsed and the Java generated in your browser, so an internal API description never leaves the page.
- Should I generate a class or an interface?
- An interface if you intend to regenerate. The mappings live on the interface and stay in
step with the spec, while your implementation stays untouched in its own class. A class is the quicker
start: each method throws
UnsupportedOperationExceptionuntil you fill it in. - How are the files split up?
- One per tag, because a spec's tags are already the author's grouping. An operation with no
tag lands in
DefaultController. Tags that differ only by case become one controller, and the notes under the toolbar say so. - What if two operations end up with the same method name?
- They are given distinct names and a note explains which operation ids collided. The same
applies to two parameters that reduce to one Java argument, and to a parameter called
bodybeside a request body. The wire names stay in the annotations, so the mappings are unchanged and the code compiles. - Do I get the DTOs too?
- Not from this page. Set the DTO package here so the controllers import them, then generate the model classes with the OpenAPI to Java DTO generator from the same spec.