Sridhar
Sridhar

Reputation: 1962

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

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

Upvotes: 6

Views: 8143

Answers (1)

Sridhar
Sridhar

Reputation: 1962

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>

Upvotes: 20

Related Questions