我有以下openapi
文档。我预计生成的 API 类名将是 SampleApi
因为操作“/hello”被标记为“sample”
tags
。但它使用 operation
生成 API 类名名字,是HelloApi
。我在这里缺少什么?我正在使用openapi-generator-maven-plugin
版本3.3.1
openapi: "3.0.0"
info:
version: 1.0.0
title: Sample Service
tags:
- name: sample
paths:
/hello:
get:
summary: Says hello world
operationId: greet
tags:
- sample
responses:
200:
description: ok
content:
plain/text:<br/>
schema:
type: string
example: Hello World
最佳答案
我找到了解决方案。我们需要在 openapi-generator-maven-plugin
的 configOptions
部分使用选项 useTags
设置为 true
默认情况下,useTags
设置为 false
,因此它不会使用标记名称来创建 API 类名称。
<configOptions>
<sourceFolder>openapi</sourceFolder>
<interfaceOnly>true</interfaceOnly>
<useBeanValidation>true</useBeanValidation>
<dateLibrary>java8-localdatetime</dateLibrary>
<useTags>true</useTags>
</configOptions>
关于java - openapi-code-generator 3.3.4 不读取标签并且 API 类名不是预期的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54310911/