首页 > 解决方案 > 如何使用自定义响应类而不是使用spring默认的ResponseEntity

问题描述

我正在使用 openapi-generator-maven-plugin 生成类。使用以下依赖项

    <build>

        <plugins>

            <plugin>

                <groupId>org.openapitools</groupId>

                <artifactId>openapi-generator-maven-plugin</artifactId>

                <version>4.0.3</version>

                <executions>

                    <execution>

                        <goals>

                            <goal>generate</goal>

                        </goals>

                        <configuration>

                            <inputSpec>${swagger.gen.product.componentsYaml}</inputSpec>

                            <generatorName>spring</generatorName>

                            <modelPackage>${swagger.gen.srcPackage}.model</modelPackage>

                            <apiPackage>${swagger.gen.srcPackage}.api.controller</apiPackage>

                            <configOptions>

                                <interfaceOnly>true</interfaceOnly>

                                <sourceFolder>src/main/java</sourceFolder>

                                <java8>true</java8>

                                <dateLibrary>java8</dateLibrary>

                            </configOptions>

                            <verbose>true</verbose>

                            <generateSupportingFiles>true</generateSupportingFiles>

                            <generateApiTests>true</generateApiTests>

                            <generateModelTests>true</generateModelTests>

                        </configuration>

                    </execution>

                </executions>

            </plugin>

            <plugin>

                <artifactId>maven-jar-plugin</artifactId>

            </plugin>

        </plugins>

 

    </build>

生成的 java api 具有返回类型org.springframework.http.ResponseEntity


我想使用自定义响应类型,而不是使用默认响应类型。有什么方法可以实现吗?

标签: openapi-generator

解决方案


推荐阅读