openapi-code-generator 3.3.4 不读取标签并且不需要 API 类名

Sri*_*har 2 java java-8 openapi-generator

我有以下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:
schema: type: string example: Hello World

Sri*_*har 9

我找到了解决方案。我们需要使用选项useTags设置为trueconfigOptions的部分openapi-generator-maven-plugin

默认useTags设置为false所以它不会使用标签名称来创建 API 类名称。

<configOptions>
  <sourceFolder>openapi</sourceFolder>
  <interfaceOnly>true</interfaceOnly>
  <useBeanValidation>true</useBeanValidation>
  <dateLibrary>java8-localdatetime</dateLibrary>
  <useTags>true</useTags>
</configOptions>
Run Code Online (Sandbox Code Playgroud)

  • 我有两个路径,和你做的一样,但是生成的api接口名为DefaultApi,你知道是什么原因吗? (2认同)