Estou tentando gerar código Java a partir do seguinte exemplo de especificação OpenAPI
openapi: "3.0.3"
info:
title: Demo API
version: "1.0"
servers:
- url: http://localhost:8080/api
description: Local development server
tags:
- name: Common
description: Operations related to common functionalities. Define multiple tags to generate multiple Api classes.
- name: Other
description: To test generation of separate APIs
paths:
/UM/{id}:
get:
tags:
- Common
description: Retrieve UM by ID
operationId: GetUM
parameters:
- in: path
name: id
schema:
type: string
required: true
responses:
"200":
description: UM
content:
application/json:
schema: { }
"404":
description: UM not found
content:
text/plain:
schema:
type: string
/UM:
post:
tags:
- Common
description: Create new UM
operationId: CreateUM
requestBody:
required: true
content:
application/json:
schema: { }
responses:
201:
description: ID of the newly created UM
content:
text/plain:
schema:
type: string
/palettes/{id}:
get:
tags:
- Common
operationId: getPalette # necessary to generate proper method name
description: Retrieve a palette by its id
parameters:
- in: path
name: id
schema:
type: integer
required: true
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/Palette"
examples:
Default:
value:
id: 1
firstName: John
lastName: Doe
role: user
"404":
description: Palette not found
content:
text/plain:
schema:
type: string
/palettes:
get:
tags:
- Common
operationId: listPalettes
description: Returns the list of palettes
responses:
"200":
description: OK
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/Palette"
put:
tags:
- Common
operationId: createPalette # necessary to generate proper method name
description: Creates a new palette
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/NewPalette"
responses:
"201":
description: Created
content:
text/plain:
schema:
type: integer
"400":
description: Validation errors
content:
application/json:
schema:
$ref: "#/components/schemas/ValidationError"
/orders:
put:
tags:
- Common
operationId: sendOrder
description: Sends a dummy order
responses:
"200":
description: OK
content:
text/plain:
schema:
type: string
/otherresources:
get:
tags:
- Other
operationId: getOther # necessary to generate proper method name
description: Example operation
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/Palette"
components:
schemas:
ObjectType:
type: string
enum: [ ENGINE, SEAT ]
Palette:
type: object
x-tags:
- Common
properties:
id:
type: integer
description: The user ID
firstName:
type: string
description: The user's first name
lastName:
type: string
description: The palette's last name
minLength: 1
maxLength: 20
role:
$ref: "#/components/schemas/ObjectType"
NewPalette:
type: object
properties:
firstName:
type: string
description: The user's first name
lastName:
type: string
description: The user's last name
minLength: 1
maxLength: 20
role:
$ref: "#/components/schemas/ObjectType"
ValidationErrorField:
properties:
field:
type: string
message:
type: string
constraint:
type: string
value:
type: string
example:
- field: name
message: size must be between 1 and 20
constraint: Size
value: This is way toooooooo long a name!
ValidationError:
properties:
status:
type: string
message:
type: string
errors:
type: array
$ref: "#/components/schemas/ValidationErrorField"
example:
- status: Bad Request
message: Validation failed
errors:
- field: lastName
message: size must be between 1 and 20
constraint: Size
value: This is wayyyyyy toooo loooooong
securitySchemes:
oidc:
type: oauth2
flows:
authorizationCode:
authorizationUrl: http://localhost:8180/realms/quarkus/protocol/openid-connect/auth
tokenUrl: http://localhost:8180/realms/quarkus/protocol/openid-connect/token
refreshUrl: http://localhost:8180/realms/quarkus/protocol/openid-connect/token
scopes:
openid: OpenID Connect authentication
security:
- oidc: [ ]
Estou construindo isso com a seguinte tarefa Gradle:
openApiGenerate {
generatorName = 'jaxrs-spec'
inputSpec = file(openapiSourcefile).absolutePath
outputDir = file(openapiGeneratedSources).absolutePath
apiPackage = "${apiPackageName}.controller"
modelPackage = "${apiPackageName}.model"
generateAliasAsModel = true
verbose = true
globalProperties = [
'apis' : project.ext.apisToGenerate,
'models': 'true'
]
configOptions = [
interfaceOnly : 'true',
singleContentTypes : 'true',
useSingleRequestMethod : 'true',
useSwaggerAnnotations : 'false',
useTags : 'true',
dateLibrary : 'java8',
library : 'quarkus',
useMicroProfileOpenAPIAnnotations : 'true',
additionalModelTypeAnnotations : '@jakarta.validation.constraints.NotNull',
useBeanValidation : 'true',
useJakartaEe : 'true',
disallowAdditionalPropertiesIfNotPresent: 'false',
generateModelTests : 'false',
generateModelDocumentation : 'false',
generateApiTests : 'false',
generateApiDocumentation : 'false',
generateBuilders : 'true',
modelPropertyNaming : 'original',
returnResponse : 'true',
]
}
E a propriedade project.ext.apisToGenerate está definida como 'Common'. O problema que tenho é que os modelos não são gerados. Eles são gerados somente quando removo a seleção de apis para gerar. Mas preciso gerar apenas as apis para tags específicas.
Qualquer ajuda é bem-vinda.
Preciso listar explicitamente os modelos que preciso gerar na propriedade 'models'?