OpenAPITools / OpenAPITools/openapi-generator
[BUG] Kotlin-server generates singular type instead of list for responses of type array
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
In kotlin-server generator (library jaxrs-spec, interfaceOnly=true) generated code for array response uses only singular type, not the expected List.
Expected result (generated with 7.2.0):
package org.openapitools.server.apis;
import javax.ws.rs.*
import javax.ws.rs.core.Response
import java.io.InputStream
@Path("/")
@javax.annotation.Generated(value = arrayOf("org.openapitools.codegen.languages.KotlinServerCodegen"))
interface DefaultApi {
@POST
@Path("/example")
@Consumes("application/json")
@Produces("application/json")
fun shouldReturnArray( body: kotlin.String): kotlin.collections.List<kotlin.String>
}
Actual result (generated with 7.3.0, 7.4.0-SNAPSHOT):
package org.openapitools.server.apis;
import javax.ws.rs.*
import javax.ws.rs.core.Response
import java.io.InputStream
@Path("/")
@javax.annotation.Generated(value = arrayOf("org.openapitools.codegen.languages.KotlinServerCodegen"))
interface DefaultApi {
@POST
@Path("/example")
@Consumes("application/json")
@Produces("application/json")
fun shouldReturnArray( body: kotlin.String): kotlin.String
}
openapi-generator version
7.3.0
OpenAPI declaration file content or url
openapi: 3.0.0
info:
description: test
version: 0.0.1
title: test
paths:
/example:
post:
summary: Example endpoint
operationId: should-return-array
requestBody:
required: true
content:
application/json:
schema:
type: string
responses:
200:
description: successful operation
content:
application/json:
schema:
type: array
items:
type: string
Generation Details
openapi-generator-cli generate -i test.openapi.yaml -g kotlin-server --library jaxrs-spec -o /tmp/openapi-test -p interfaceOnly=true
Steps to reproduce
Issue can be reproduced with above openapi specification and CLI command.
Related issues/PRs
Suggest a fix
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the openapi-generator-cli generate command using -g kotlin-server, --library jaxrs-spec, and interfaceOnly=true, along with the YAML specification in the report. Reproduce the generated DefaultApi response and trace the Kotlin server generation path; done means an array response produces kotlin.collections.List<kotlin.String> rather than kotlin.String.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin, openapi
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100