SpringCloud - Add a prefix for configuration files generated
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Start with the spring-cloud generator templates that produce ApiKeyRequestInterceptor and ClientConfiguration, using the Maven configuration and generated class names in the issue as the entry point. Trace every generated reference to these classes, then verify that a configurable prefix renames the files and usages so multiple clients no longer create conflicting clientConfiguration beans.
Written by the indexing model from the issue text.
Description
When generating a Spring Boot client with
<plugin>
<groupId>io.swagger.codegen.v3</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>3.0.34</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/myapi.yaml</inputSpec>
<output>${project.build.directory}/generated-sources/client</output>
<language>spring</language>
<library>spring-cloud</library>
<generateModels>true</generateModels>
<modelPackage>${clientBasePackage}.model</modelPackage>
<generateApis>true</generateApis>
<apiPackage>${clientBasePackage}.api</apiPackage>
<generateModelTests>false</generateModelTests>
<generateModelDocumentation>false</generateModelDocumentation>
<generateApiTests>false</generateApiTests>
<generateApiDocumentation>false</generateApiDocumentation>
<configOptions>
<configPackage>${clientBasePackage}.config</configPackage>
<dateLibrary>java11</dateLibrary>
<title>${api-name}</title>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
the generated files in the package config are always
├───config
│ ApiKeyRequestInterceptor.class
│ ClientConfiguration.class
It is a problem when I have multiple clients injected in the same Spring Boot application. In that case the application is not starting and complains about a conflict between beans with the same name (clientConfiguration).
Is it possible to add an option like MyApi allowing to have
├───config
│ MyApiApiKeyRequestInterceptor.class
│ MyApiClientConfiguration.class
And of course renaming all the usages within other generated files.
The only solution I found is to add
<plugin>
<groupId>com.coderplus.maven.plugins</groupId>
<artifactId>copy-rename-maven-plugin</artifactId>
<version>1.0.1</version>
<executions>
<execution>
<id>rename-ApiKeyRequestInterceptor</id>
<phase>generate-sources</phase>
<goals>
<goal>rename</goal>
</goals>
<configuration>
<sourceFile>${project.build.directory}/generated-sources/client/src/main/java/.../config/ApiKeyRequestInterceptor.java</sourceFile>
<destinationFile>${project.build.directory}/generated-sources/client/src/main/java/.../config/MyApiApiClientApiKeyRequestInterceptor.java</destinationFile>
</configuration>
</execution>
<execution>
<id>rename-ClientConfiguration</id>
<phase>generate-sources</phase>
<goals>
<goal>rename</goal>
</goals>
<configuration>
<sourceFile>${project.build.directory}/generated-sources/client/src/main/java/.../config/ClientConfiguration.java</sourceFile>
<destinationFile>${project.build.directory}/generated-sources/client/src/main/java/.../config/MyApiApiClientConfiguration.java</destinationFile>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.3</version>
<executions>
<execution>
<id>replace-for-ApiKeyRequestInterceptor</id>
<phase>generate-sources</phase>
<goals>
<goal>replace</goal>
</goals>
<configuration>
<basedir>${project.build.directory}/generated-sources/client/src/main/java/.../config</basedir>
<includes>
<include>**/*.java</include>
</includes>
<replacements>
<replacement>
<token>ApiKeyRequestInterceptor</token>
<value>MyApiApiClientApiKeyRequestInterceptor</value>
</replacement>
</replacements>
</configuration>
</execution>
<execution>
<id>replace-for-ClientConfiguration</id>
<phase>generate-sources</phase>
<goals>
<goal>replace</goal>
</goals>
<configuration>
<basedir>${project.build.directory}/generated-sources/client/src/main/java/...</basedir>
<includes>
<include>**/*.java</include>
</includes>
<replacements>
<replacement>
<token>ClientConfiguration</token>
<value>MyApiApiClientConfiguration</value>
</replacement>
</replacements>
</configuration>
</execution>
</executions>
</plugin>
But it's really boring...
- Dominant language
- Mustache
- Stars
- 299
- Forks
- 439
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing 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.
More from swagger-api/swagger-codegen-generators
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
[Bug]: Python/pythonFlaskConnexion generators validate map keys instead of values for additionalProperties.enumPossibly taken @pvillard31 claimed this 208 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
Python generated code: Delete API Requests can be blocked in API Gateways when sends empty bodyOpen
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
[Bug]: Bean validation doesn't work for numbers larger than Integer.MAX_VALUEPossibly taken @apupier claimed this 296 days ago. OpenBug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
swagger-api/swagger-codegen-generators#1370 · 3 comments · 1 reaction ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
All issues in swagger-api/swagger-codegen-generators
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
ROCm/rocm-libraries#15665 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
shadps4-emu/shadPS4#5705 ·
Maintainers usually reply within 1 day
-
bug multiple issues priority: high
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
storytold/gridcraft#3928 · 1 comment ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Qiskit/qiskit-aer#2533 ·
Maintainers usually reply within 1 day