SpringCloud - Add a prefix for configuration files generated
还没有人认领这个 Issue。
评估
调研方向
从生成 ApiKeyRequestInterceptor 和 ClientConfiguration 的 spring-cloud 生成器模板开始,以 issue 中的 Maven 配置和生成的类名作为切入点。追踪对这些类的每个生成引用,然后验证可配置的前缀是否会重命名文件和使用位置,从而使多个客户端不再创建相互冲突的 clientConfiguration bean。
由索引模型根据 Issue 内容生成。
描述
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...
- 主要语言
- Mustache
- 星标
- 299
- 派生
- 439
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
swagger-api/swagger-codegen-generators 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
-
[Bug]: Python/pythonFlaskConnexion generators validate map keys instead of values for additionalProperties.enum可能已有人在做 @pvillard31 于 208 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 86/100
-
难度 2/5 1-3 小时 新手友好度 68/100
-
[Bug]: Bean validation doesn't work for numbers larger than Integer.MAX_VALUE可能已有人在做 @apupier 于 296 天前认领。 未关闭Bug
难度 2/5 1-3 小时 新手友好度 68/100
swagger-api/swagger-codegen-generators#1370 · 3 条评论 · 1 个 reaction ·
-
难度 2/5 1-3 小时 新手友好度 64/100
查看 swagger-api/swagger-codegen-generators 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 74/100
ROCm/rocm-libraries#15665 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
shadps4-emu/shadPS4#5705 ·
维护者通常 1 天内回复
-
bug multiple issues priority: high
难度 2/5 1-3 小时 新手友好度 78/100
storytold/gridcraft#3928 · 1 条评论 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 65/100
Qiskit/qiskit-aer#2533 ·
维护者通常 1 天内回复