OpenAPITools / OpenAPITools/openapi-generator
[BUG][scala-akka-http-server]When there are several header parameters, curly brackets are wrongly closed
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
When a method contains several header parameters, some closing curly brackets are missing and the file is thus badly formatted.
openapi-generator version
7.3.0
OpenAPI declaration file content or url
openapi: 3.0.2
info:
version: 1.0.17
title: Swagger Petstore - OpenAPI 3.0
paths:
'/pet/{petId}':
delete:
summary: Deletes a pet
description: ''
operationId: deletePet
parameters:
- name: api_key
in: header
description: ''
required: false
schema:
type: string
- name: requestId
in: header
description: ''
required: false
schema:
type: string
- name: petId
in: path
description: Pet id to delete
required: true
schema:
type: integer
format: int64
responses:
'400':
description: Invalid pet value
Command line used for generation
java -jar openapi-generator-cli-7.3.0.jar generate -g scala-akka-http-server -i petstore.yml
Steps to reproduce
The DefaultApi.scala generated with previous command on example above is the following:
package org.openapitools.server.api
import akka.http.scaladsl.server.Directives._
import akka.http.scaladsl.server.Route
import akka.http.scaladsl.model.StatusCodes
import org.openapitools.server.AkkaHttpHelper._
class DefaultApi(
defaultService: DefaultApiService
) {
lazy val route: Route =
path("pet" / LongNumber) { (petId) =>
delete {
optionalHeaderValueByName("api_key") { apiKey => optionalHeaderValueByName("requestId") { requestId =>
defaultService.deletePet(petId = petId, apiKey = apiKey, requestId = requestId)
}
}
}
}
trait DefaultApiService {
def deletePet400: Route =
complete((400, "Invalid pet value"))
/**
* Code: 400, Message: Invalid pet value
*/
def deletePet(petId: Long, apiKey: Option[String], requestId: Option[String]): Route
}
Related issues/PRs
None
Suggest a fix/enhancement
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 by running the provided generator command with the example OpenAPI declaration and inspect the generated DefaultApi.scala route for the header parameters. Compare the braces around apiKey and requestId, then verify that generated Scala output is correctly balanced and formatted when several headers are present.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi, scala
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100