我在 springboot 应用程序中使用 openapi-generator-maven-plugin 从 yaml 文件生成 java 类。 我想让所有端点都抛出 CustomException。
如何配置插件来做到这一点?
这是 open-ui.yaml。我定义了返回 UserDto 列表的端点“用户”。我希望该方法在签名中抛出异常。
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'
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>