openapi-code-generator 3.3.4 does not read the tags and API class name is not expected
Asked Answered
P

1

6

I have below openapi document. I expected the API class name to be generated will be SampleApi because the operation "/hello" is tagged with "sample" tags. But it is generating the API class name using the operation name, it is HelloApi. What am I missing here? I am using openapi-generator-maven-plugin version 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

Prevalent answered 22/1, 2019 at 14:54 Comment(0)
P
20

I found solution. We need to use option useTags set to true in the configOptions section of the openapi-generator-maven-plugin

By default useTags set to false so it will not use the tag name to create the API class name.

<configOptions>
  <sourceFolder>openapi</sourceFolder>
  <interfaceOnly>true</interfaceOnly>
  <useBeanValidation>true</useBeanValidation>
  <dateLibrary>java8-localdatetime</dateLibrary>
  <useTags>true</useTags>
</configOptions>
Prevalent answered 23/1, 2019 at 14:21 Comment(1)
I have two paths, doing the same as you, but api interface generated is named DefaultApi, do you know what is the reason?Automation

© 2022 - 2024 — McMap. All rights reserved.