swagger-api / swagger-api/swagger-codegen
[JavaJaxRS] ServiceImpl and ServiceFactory classes should not be overwritten
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
Prior to #4074, all generated *ServiceImpl and *ServiceFactory classes would never be overwritten due to io.swagger.codegen.languages.AbstractJavaJAXRSServerCodegen#shouldOverwrite which was removed in the previously mentioned issue. I believe that the previous behavior was correct because those classes are intended to contain user-written code and are also written to a different directory than the rest of the generated classes. There's no reason to allow them to be overwritten and this change breaks anyone that relied on this.
Swagger-codegen version
2.2.2-SNAPSHOT
Swagger declaration file content or url
Command line used for generation
<plugin>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>2.2.2-SNAPSHOT</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/api.yml</inputSpec>
<language>jaxrs</language>
<output>${project.basedir}</output>
<modelPackage>com.foo.model</modelPackage>
<apiPackage>com.foo.api</apiPackage>
<configOptions>
<dateLibrary>java8</dateLibrary>
<sourceFolder>src/generated/java</sourceFolder>
</configOptions>
<environmentVariables>
<hideGenerationTimestamp/>
<models/>
<apis/>
<supportingFiles>
ApiException.java,ApiOriginFilter.java,ApiResponseMessage.java,JacksonJsonProvider.java,NotFoundException.java,StringUtil.java,RFC3339DateFormat.java
</supportingFiles>
</environmentVariables>
<addCompileSourceRoot>false</addCompileSourceRoot>
</configuration>
</execution>
</executions>
</plugin>
Steps to reproduce
Related issues
Suggest a Fix
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
Start with io.swagger.codegen.languages.AbstractJavaJAXRSServerCodegen#shouldOverwrite and inspect the referenced #4074 diff. Verify how Java JAX-RS generation handles existing *ServiceImpl and *ServiceFactory classes. Done means those user-written classes are no longer overwritten while other generated files retain their expected behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend, devtools
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100