OpenAPITools / OpenAPITools/openapi-generator
[BUG] Spring boot 3 - can't see interfaces with default methods. "Ignored because not a concrete top-level class"
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
I'm moving to spring boot 3, generating the interface only classes, all annotations work correctly.
When starting in spring the class is scanned, but for the generated interfaces with default methods
spring logs ::
o.s.c.a.ClassPathBeanDefinitionScanner : Ignored because not a concrete top-level class:
I've tested with spring boot versions 3.0.x 3.1.x and 3.2.x and the same issue appears
openapi-generator version
7.4.0
Generation Details
org.openapitools openapi-generator-maven-plugin 7.4.0 generate ${project.build.directory}/classes/contract/contract.yaml spring true ApiUtil.java <generateApis>true</generateApis>
<generateApiTests>false</generateApiTests>
<generateModelTests>false</generateModelTests>
<apiPackage>true</apiPackage>
<modelPackage>true</modelPackage>
<apiPackage>com.api</apiPackage>
<modelPackage>com.model</modelPackage>
<modelNameSuffix></modelNameSuffix>
<output>${project.build.directory}/generated-sources</output>
<configOptions>
<useResponseEntity>true</useResponseEntity>
<enablePostProcessFile>true</enablePostProcessFile>
<interfaceOnly>true</interfaceOnly>
<java8>true</java8>
<sourceFolder>openapi</sourceFolder>
<dateLibrary>java8</dateLibrary>
<useSpringBoot3>true</useSpringBoot3>
<useSpringController>true</useSpringController>
<library>spring-boot</library>
<useTags>true</useTags>
<templateDirectory>src/main/resources/mustache</templateDirectory>
<useBeanValidation>true</useBeanValidation>
<performBeanValidation>true</performBeanValidation>
<useOptional>true</useOptional>
<hideGenerationTimestamp>true</hideGenerationTimestamp>
<unhandledException>true</unhandledException>
<useSwaggerUI>false</useSwaggerUI>
<annotationLibrary>none</annotationLibrary>
<documentationProvider>none</documentationProvider>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
Steps to reproduce
Generate the interface as normal from the contract (my generator config is above)
enable spring logging to see
logging.level.org.springframework.core.io.support=DEBUG
logging.level.org.springframework.context.annotation=DEBUG
Watch the interface be ignored.
Related issues/PRs
none I can see
Suggest a fix
You need to implement your interfaces, and annotate them with @RestController
you don't need any other annotation.
The default interface methods sadly will be ignored.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Begin with the spring generator selected by generatorName=spring and the interfaceOnly and useSpringBoot3 options in the Maven configuration. Reproduce the generation and inspect the resulting interfaces and Spring scan logs; done means the generated API interfaces are implemented and annotated so Spring no longer ignores them.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring-boot
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100