GHA*_*SEN 5 maven-plugin spring-boot springdoc-openui
我正在使用 openapi-generator-maven-plugin 从 springboot 应用程序中的 yaml 文件生成 java 类。我想让所有端点抛出 CustomException。
如何配置插件来做到这一点?
这是 open-ui.yaml。我定义了返回 UserDto 列表的端点“users”。我希望该方法在签名中抛出异常。
openapi: "3.0.0"
info:
version: 1.0.0
title: Test Api
license:
name: MIT
servers:
- url: "https://{domain}/test/{basePath}"
paths:
/users:
get:
summary: users
operationId: getUsers
tags:
- users
parameters:
- name: limit
in: query
schema:
type: integer
responses:
'200':
description: A page of users
content:
application/v1+json; charset=utf-8:
schema:
type: array
items:
$ref: '#/components/schemas/UserDto'
Run Code Online (Sandbox Code Playgroud)
pom.xml
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>5.3.1</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>
${project.basedir}/swagger/open-ui.yaml
</inputSpec>
....
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
有同样的问题:)对应于官方文档(https://openapi-generator.tech/docs/generators/spring/),只需添加<unhandledException>true</unhandledException>到<configOptions>
<configuration>
...
<configOptions>
...
<unhandledException>true</unhandledException>
...
</configOptions>
</configuration>
Run Code Online (Sandbox Code Playgroud)
这会生成带有“抛出异常”的 API。
| 归档时间: |
|
| 查看次数: |
1657 次 |
| 最近记录: |