You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Starting version 5.0.0, it is impossible to generate compiling code when using HTTP OPTIONS in an API. It used to work just fine as the generated code was using @RequestMapping, defining the RequestMethod.
openapi-generator version
>= 5.0.0
OpenAPI declaration file content
openapi: 3.0.3info:
title: kotlin-spring generator bug reportversion: v1paths:
/world:
options:
operationId: optionstags:
- hellosummary: This will generate code that cannot compileresponses:
200:
description: Hello world!content:
application/json:
example:
{ }
Generation Details
Generated code looks as follow
/** * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.0.0). * https://openapi-generator.tech * Do not edit the class manually.*/packagecom.bugreport.apiimportorg.springframework.http.HttpStatusimportorg.springframework.http.MediaTypeimportorg.springframework.http.ResponseEntityimportorg.springframework.web.bind.annotation.*importorg.springframework.validation.annotation.Validatedimportorg.springframework.web.context.request.NativeWebRequestimportorg.springframework.beans.factory.annotation.Autowiredimportjavax.validation.Validimportjavax.validation.constraints.DecimalMaximportjavax.validation.constraints.DecimalMinimportjavax.validation.constraints.Maximportjavax.validation.constraints.Minimportjavax.validation.constraints.NotNullimportjavax.validation.constraints.Patternimportjavax.validation.constraints.Sizeimportkotlin.collections.Listimportkotlin.collections.Map
@Validated
@RequestMapping("\${api.base-path:}")
interfaceWorldApi {
@OptionsMapping(
value = ["/world"],
produces = ["application/json"]
)
funoptions(): ResponseEntity<Unit> {
returnResponseEntity(HttpStatus.NOT_IMPLEMENTED)
}
}
The previous version was covering all cases, at the price of a bit of verbosity on generated code, which is not an issue. The PR can only work for CRUD operations, but all other HTTP methods were lost as a consequence.
As reference, RequestMethod in Spring is defined as:
Description
Starting version 5.0.0, it is impossible to generate compiling code when using HTTP OPTIONS in an API. It used to work just fine as the generated code was using
@RequestMapping
, defining theRequestMethod
.openapi-generator version
>= 5.0.0
OpenAPI declaration file content
Generation Details
Generated code looks as follow
Steps to reproduce
openapi-generator-cli generate -i bugreport.yml -g kotlin-spring
Related issues/PRs
#7189 (comment)
Suggest a fix
Rollback.
The previous version was covering all cases, at the price of a bit of verbosity on generated code, which is not an issue. The PR can only work for CRUD operations, but all other HTTP methods were lost as a consequence.
As reference,
RequestMethod
in Spring is defined as:Existing Spring annotations are:
Anybody using HTTP HEAD, OPTIONS or TRACE will be unable to use the generator.
The text was updated successfully, but these errors were encountered: