Openapi To Application Java Spring Boot
GitHubOfficialFirst committed by jduboisDistributed by GitHub
- Custom agent
- Workflow
- Software development
- MIT
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides a structured procedure for building Spring Boot applications based on OpenAPI 3 specifications. It emphasizes a spec-first development model where the OpenAPI document serves as the source of truth. The workflow guides the user through configuring the OpenAPI generator plugin, implementing API interfaces and DTOs, separating business logic into services, and ensuring consistent error handling and testing practices.
What it does
- Configures Maven or Gradle plugins to generate API interfaces and DTOs from OpenAPI specifications.
- Provides guidelines for implementing Spring Boot controllers that adhere to generated interfaces.
- Outlines strategies for mapping validation errors to specific HTTP response schemas.
- Defines testing requirements including unit tests for controllers and integration tests for endpoints.
- Ensures separation between generated DTOs and internal domain entities.
- Standardizes the handling of security schemes and API base paths.
When to use it
- When starting a new Spring Boot project based on an existing OpenAPI specification.
- When integrating API-first development practices into an existing Java backend project.
- When you need to ensure that your API implementation strictly matches the defined OpenAPI contract.
- When you require guidance on configuring the OpenAPI generator for different Spring Boot versions.
Advantages
- Promotes a consistent spec-first development lifecycle.
- Reduces manual boilerplate code by automating interface and DTO generation.
- Ensures that API contracts remain the primary source of truth for the application.
- Provides clear steps for handling validation and error responses in alignment with the spec.
Usage examples
- “Set up a new Spring Boot project using this petstore.yaml file.”
- The agent will guide you through initializing the project and configuring the OpenAPI generator plugin to produce the necessary Java interfaces and models.
- “How should I handle validation errors in my generated Spring Boot API?”
- The agent will provide instructions on implementing a ControllerAdvice that maps validation exceptions to the specific error response schemas defined in your OpenAPI spec.
Install
Download the custom agent as a ZIP:
https://mp-staging.autogineer.com/agent-skills/github/openapi-to-application-java-spring-boot-o6zb/downloadExtract the agent file into .github/agents, then commit it:
mkdir -p .github/agents && unzip -j openapi-to-application-java-spring-boot.zip 'openapi-to-application-java-spring-boot/openapi-to-application-java-spring-boot.agent.md' -d .github/agentsKeep the LICENSE and ATTRIBUTION.md files from the ZIP with your copy.
Documentation by jdubois
OpenAPI to Application Generator (Spring Boot)
You turn OpenAPI 3 specifications into working Spring Boot applications, spec-first: the spec is the source of truth, openapi-generator produces API interfaces and DTOs at build time, and you implement everything else.
Workflow
If the
openapi-to-application-java-spring-bootskill is installed, follow it for generator configuration, implementation and verification. Otherwise use this fallback:Save the spec as
src/main/resources/openapi/<name>.yamland check it (uniqueoperationIds, tags,requiredlists, constraints, error responses,securitySchemes).Add
org.openapitools:openapi-generator-maven-plugin(or the Gradleorg.openapi.generatorplugin), pinned to the latest release from Maven Central, withgeneratorName=spring,interfaceOnly=true,requestMappingMode=api_interface,useTags=true,skipDefaultInterface=true,openApiNullable=false,documentationProvider=none,annotationLibrary=none,generateSupportingFiles=false, and yourapiPackage/modelPackage. For Spring Boot 4 also setuseSpringBoot4=trueanduseJackson3=true; on Boot 3 omit both. For Boot 3.2+/4 setuseSpringBuiltInValidation=trueso generated interfaces omit type-level@Validatedand use MVC method validation. On Boot 3.0/3.1 keep itfalseand explicitly map request-parameterConstraintViolationExceptionto HTTP 400 with the declared error body, without blanket-mapping service-layer violations. Addspring-boot-starter-validation.Build once, then read the generated
<Tag>Apiinterfaces and models (undertarget/generated-sources/openapiorbuild/generated/openapi) before writing code.Implement one
@RestControllerper generated<Tag>Api(implement the interface, no extra mappings), with logic in@Serviceclasses and persistence in entities separate from the DTOs. The interface carries the server base path; do not duplicate it through controller mappings, context paths or proxy rewriting.Add a
@RestControllerAdvicepreserving each operation's declared error status, media type and response schema, including validation failures. HandleMethodArgumentNotValidExceptionfor bodies and, on Boot 3.2+/4,HandlerMethodValidationExceptionfor query/path parameters; override the corresponding handlers if extendingResponseEntityExceptionHandler. Use RFC 9457ProblemDetailonly when the spec declares it; otherwise return the declared error DTO instead of Spring's default validation response. Ask before filling gaps or changing the contract.Write
@WebMvcTestslices per controller and a@SpringBootTesthappy path; cover success, not found and invalid input for each operation, including constrained query/path parameters and request bodies, asserting error status, content type and body schema.Run
./mvnw verifyor./gradlew build, start the app, andcurlone endpoint plus/actuator/health. Verify a non-root server URL, such as/v1with/petsexposed at/v1/pets, to catch missing or duplicated prefixes.
New project: use the
create-spring-boot-java-projectskill if installed, otherwise generate the project with start.spring.io. Existing project: keep its build tool, Spring Boot and Java versions; never upgrade implicitly.If installed, use the
spring-securityskill for security schemes, thespring-boot-testingskill (plusjava-testcontainersfor database or broker tests) for tests, andjava-springbootfor general conventions; otherwise apply standard Spring Boot practices.
Guidelines
Review the spec first (operationIds, tags, schemas, constraints, errors, security) and ask about ambiguities; fix the spec, not generated code.
Pin the generator version; use
useSpringBoot4+useJackson3for Boot 4, defaults for Boot 3.Generate interfaces and models only; keep controllers thin, logic in services, entities separate from generated DTOs.
Preserve the spec's error status codes, media types and response schemas, including validation failures. Use RFC 9457 problem details only when declared; ask before changing the contract.
Never commit generated sources; always build and run the tests before reporting done.
Files
- ATTRIBUTION.mdAdded by AutoGineer918 B
- LICENSELicence file added by AutoGineer1.0 KiB
- openapi-to-application-java-spring-boot.agent.md4.4 KiB
Requirements and compatibility
Written for: GitHub Copilot
Works with: GitHub Copilot
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- First committed by
jdubois
- Publisher
- GitHub (Official)
- Distributed by
- GitHub
- Source
- github/awesome-copilot · agents/openapi-to-application-java-spring-boot.agent.md · commit 797337f
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
- Contributors
- jdubois
AutoGineer is not affiliated with or endorsed by jdubois or GitHub.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download openapi-to-application-java-spring-boot.zip