spring - 从 spring boot rest 控制器自动生成 typescript api
问题描述
我目前正在从 .json 定义文件中自动生成 typescript-angular 代码。我发现,当我从 swagger 访问/v2/api-docs
页面时,swagger 会自动按名称标记我的 REST 控制器并将其写入定义文件。结果是,codegen 工具生成了多个很酷的服务文件。
kongchen
在编译期间生成此 json的工具不会这样做。因此它只是写入所有端点,但没有以正确的形式对其进行标记,因此所有内容都放入同一个default.service.ts
文件中。
有什么我错过的吗?所以最后我想要一个包含标签的swagger定义文件,这样就不会default.service.ts
生成大的但是user.service.ts
等等pet.service.ts
。
<plugin>
<groupId>com.github.kongchen</groupId>
<artifactId>swagger-maven-plugin</artifactId>
<version>3.1.6</version>
<configuration>
<apiSources>
<apiSource>
<springmvc>true</springmvc>
<locations>
<location>com.project.main.Controller</location>
</locations>
<schemes>http</schemes>
<host>localhost:9999</host>
<basePath>/</basePath>
<info>
<title>Swagger Maven Plugin Spring Boot for cars</title>
<version>v1</version>
<description>Working sample of Spring Boot for cars annotations</description>
<termsOfService>
http://www.githubproeas.com
</termsOfService>
<contact>
<email>carsexample@email.com</email>
<name>Cars Example</name>
<url>http</url>
</contact>
<license>
<url>http://www.license.com</url>
<name>License name</name>
</license>
</info>
<outputFormats>json</outputFormats>
<swaggerDirectory>${basedir}/src/main/resources</swaggerDirectory>
</apiSource>
</apiSources>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
解决方案
推荐阅读
- python - 将 .pb 从 Tensorflow 1.14 迁移到 2.0
- c++ - 如何确保我的 `ifstream` 文件对象指向的文件内容已更新?
- javascript - 获取特定的 td 值进行计算
- java - 预期方法调用
- c# - 在处理下一个查询之前批处理数据库结果
- javascript - 如何将发送到快递的请求重定向到外部资源?
- c - 通过 scanf() 提取输入字符串的一部分
- javascript - 强制~同步 Node.js IPC
- ruby-on-rails - 如何在 rspec 中获取有关 JS 错误的信息?
- c - 如何使用 LLVM 或其他工具标记基本块的边界?