У меня есть эта конфигурация для плагина maven:
Файл конфигурации определяет пакеты для модели и для api.
Спецификация OpenApi выглядит так:
Сгенерированный code содержит метод с именем answerQuery, как и ожидалось, но для этого метода нет аннотаций @ApiResponse или @Operation. Есть только комментарий javadoc, в котором перечислены три значения @return, каждое из которых имеет описание из разных codeов ответов в спецификации.
Есть ли какая-либо конфигурация для плагина maven, которая добавляет эти аннотации (из библиотеки microprofile вместо swagger)?
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>7.6.0</version>
<executions>
<execution>
<id>query</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<generateApis>true</generateApis>
<generatorName>jaxrs-spec</generatorName>
<generateSupportingFiles>false</generateSupportingFiles>
<output>${generated.source.directory}</output>
<configurationFile>${specification.source.directory}/query-config.json</configurationFile>
<inputSpec>${specification.source.directory}/query.yaml</inputSpec>
<configOptions>
<library>openliberty</library>
<serializationLibrary>jsonb</serializationLibrary>
<sourceFolder>/</sourceFolder>
<useJakartaEe>false</useJakartaEe>
<interfaceOnly>true</interfaceOnly>
<useMicroProfileOpenAPIAnnotations>true</useMicroProfileOpenAPIAnnotations>
<useSwaggerAnnotations>false</useSwaggerAnnotations>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
openapi: 3.0.3
info:
title: Generated API
version: "1.0"
servers:
- url: http://view-localhost:80/
- url: https://view-localhost:443/
tags:
- name: Query
description: Example for Stackoverflow question
paths:
/query/v1/{identity}:
get:
tags:
- Query
summary: Example for Stackoverflow question
description: Illustrate structure of real specification
operationId: answerQuery
parameters:
- name: identity
in: path
description: reference number
required: true
schema:
type: string
responses:
"200":
description: Example that should have an @ApiResponse annotation in the generated code
content:
application/json:
schema:
required:
- info
type: object
properties:
info:
type: string
nullable: false
"400":
description: "Bad Request, supplied parameters are invalid"
"401":
description: "Unauthorized, caller is not authorized to call this service"
Клавдия
Вопрос задан12 июня 2024 г.