7
Swagger固有の注釈を含むJavaファイルからJSONファイルを生成して、Swagger-UIがそれを読むことができるようにする方法。Java Swagger AnnotationをSwagger jsonスキーマに変換するにはどうすればいいですか?
<plugin>
<groupId>com.github.kongchen</groupId>
<artifactId>swagger-maven-plugin</artifactId>
<version>3.1.4</version>
<configuration>
<apiSources>
<apiSource>
<springmvc>true/false</springmvc>
<locations>
<location>com.yourpackage.something</location>
</locations>
<host>yourhost.com</host>
<basePath>/some/path</basePath>
<info>
<title>Your Project Title</title>
<version>${project.version}</version>
<description>Some nice stuff</description>
<termsOfService>...</termsOfService>
<contact>
<email>[email protected]</email>
<name>Your Name</name>
<url>www.where.to.find.you</url>
</contact>
</info>
<swaggerDirectory>path/to/swagger/output</swaggerDirectory>
<outputFormats>json</outputFormats>
</apiSource>
</apiSources>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
次にあなたがmvn compile
を行うことができますし、それがswagger.json
ファイルを生成します:あなたが闊歩Mavenプラグインを使用して、「私は手動でそれを行うにはしたくない」と言ったよう
これがどのように行われているかを示す[swagger-samples](https://github.com/swagger-api/swagger-samples)リポジトリのサンプルを見てください。それはあなたのフレームワークなどを含む多くのものに依存します。 – fehguy
私はフレームワークのためにJavaとSpringBootを使用しています。 –
swagger-samplesリポジトリでは、swagger JSONが手動で作成されると思います。私は手動でやりたいとは思わない。 –