openapi-generator
openapi-generator copied to clipboard
Generated code doen't have any information about response headers
I have following open api specification description:
openapi: 3.0.3
...
/foo:
get:
operationId: foo
parameters:
- name: bar
in: query
required: true
schema:
type: string
responses:
200:
description: description
content:
application/json:
schema:
type: array
items:
type: string
headers:
myheader1:
description: myheader1 desc
schema:
type: string
myheader2:
description: myheader2 desc
schema:
type: integer
401:
description: "Unauthorized"
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
The generated code is:
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2024-01-24T14:16:01.056664+03:00[Europe/London]")
@Validated
@Tag(name = "Default", description = "the Default API")
@RequestMapping("${openapi.directoryServiceManager.base-path:/api/v1}")
public interface DefaultApi {
/**
* GET /foo
*
* @param bar (required)
* @return description (status code 200)
* or Unauthorized (status code 401)
*/
@Operation(
operationId = "foo",
responses = {
@ApiResponse(responseCode = "200", description = "description", content = {
@Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = String.class)))
}),
@ApiResponse(responseCode = "401", description = "Unauthorized", content = {
@Content(mediaType = "application/json", schema = @Schema(implementation = ErrorDto.class))
})
}
)
@RequestMapping(
method = RequestMethod.GET,
value = "/foo",
produces = { "application/json" }
)
ResponseEntity<List<String>> foo(
@NotNull
@Parameter(name = "bar", description = "", required = true, in = ParameterIn.QUERY) @Valid @RequestParam(value = "bar", required = true) String bar
);
}
As you can see where is no information about response headers(myheader1 and myheader2)
I would expect that
ApiResponse should have headers argument added
Is there way to fix it ?
More information about environment:
buildscript {
dependencies {
classpath("org.openapitools:openapi-generator-gradle-plugin:5.0.0")
}
}
plugins {
java
kotlin("jvm")
kotlin("plugin.spring") version "1.8.21"
id("org.springframework.boot") version "3.1.4"
id("org.openapi.generator") version "6.3.0"
}
Also running into this
Any update here?