Using OpenApi generator with Spring Boot
Here is my translation.yml file:
openapi: 3.0.1
info:
title: OpenAPI definition
version: v0
servers:
- url: http://localhost:8088/
description: Generated server url
paths:
/api/translation/{module}/{locale}:
get:
tags:
- translations
summary: Get translations by module, locale and tenantId
operationId: getTranslations
parameters:
- name: module
in: path
required: true
schema:
type: string
- name: locale
in: path
required: true
schema:
type: string
- name: tenantId
in: query
required: true
schema:
type: integer
format: int64
responses:
'200':
description: Get the translations
content:
application/json:
schema:
type: object
additionalProperties:
type: string
example:
nav:
payments:
invoice:
details:
title: Payments Details
all: AllPayments
orders: Orders
dashboard: Dashboard
title: Payments
home:
title: Home
and here is pom.xml:
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>6.5.0</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>
${project.basedir}/src/main/resources/translation.yml
</inputSpec>
<generatorName>spring</generatorName>
<apiPackage>test.inbound_api</apiPackage>
<modelPackage>test.inbound_api.model</modelPackage>
<configOptions>
<interfaceOnly>true</interfaceOnly>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
- The name of generated interface is
ApiApi.java
. How to generate something likeTranslationApi.java
? RESOLVED - The generated interface method returns
ResponseEntity<Map<String, String>>
how to make it returnResponseEntity<Map<String, Object>>
? RESOLVED - How to correctly provide the
example
with tree structure? In swaggerUi I get nowExample Value "string".
Theexample
in my code displayed correctly in Swagger Editor, but not present in the generated interface class. That's what I want to achieve: