[英]How to generate model classes only from Open Api in SpringBoot?
For example this is my open api例如这是我打开的 api
openapi: "3.0.0"
paths:
/pets:
get:
summary: List all pets
operationId: listPets
tags:
- pets
parameters:
- name: limit
in: query
...
responses:
...
post:
summary: Create a pet
operationId: createPets
...
/pets/{petId}:
get:
summary: Info for a specific pet
operationId: showPetById
...
components:
schemas:
Pet:
type: object
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type: string
tag:
type: string
Error:
type: object
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string
and I want to generate only model classes not apis and other things in the com.service.model package of src/main/java instead of target folder in springboot. and I want to generate only model classes not apis and other things in the com.service.model package of src/main/java instead of target folder in springboot. What is the configuration needed in the pom.xml file?
pom.xml 文件中需要什么配置?
I think that the generated sources should always be created in the target folder and not in your source code folder.我认为生成的源代码应该始终在目标文件夹中创建,而不是在您的源代码文件夹中。 Besides that, all the code (generated or your own) will eventually be on the same classpath.
除此之外,所有代码(生成的或您自己的)最终都将位于同一类路径中。
But if you insist of changing the default location (target/generated-sources) you can add something like this to your swagger-codegen configuration in your pom.xml: <output>src/main/java</output>
但是,如果您坚持更改默认位置(目标/生成源),您可以在 pom.xml 中将类似的内容添加到您的 swagger-codegen 配置中:
<output>src/main/java</output>
To generate only the Model code you can add these tags to your codegen configuration:要仅生成 Model 代码,您可以将这些标签添加到您的代码生成配置中:
<plugin>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<executions>
<execution>
<configuration>
<generateApis>false</generateApis>
<generateModelDocumentation>false</generateModelDocumentation>
<generateSupportingFiles>false</generateSupportingFiles>
</configuration>
</execution>
</executions>
</plugin>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.