Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] [scala-akka-http-server] Datetime query parameters are mapped to String instead of OffsetDateTime #20262

Open
5 of 6 tasks
bjolletz opened this issue Dec 6, 2024 · 0 comments

Comments

@bjolletz
Copy link
Contributor

bjolletz commented Dec 6, 2024

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 generating code with scala-akka-http-server, a query parameter with type=string and format=date-time is mapped to a Scala String instead of OffsetDateTime.

openapi-generator version

7.10.0

OpenAPI declaration file content or url

Example query parameter definition:

- name: createdFrom
  in: query
  description: "Only return `Files` that were created after this date and time, expressed in ISO 8601 format."
  required: false
  schema:
    type: string
    format: date-time
Generation Details
openapi-generator generate -g scala-akka-http-server -i https://api.swaggerhub.com/apis/pagero-api/file-api/1.1.0/swagger.yaml\?resolved\=true -o out
Steps to reproduce

The generated file out/src/main/scala/org/openapitools/server/api/FileApi.scala contains the following:

    path("files") { 
      get { 
        parameters("companyId".as[String].?, "sendMode".as[String].?, "documentType".as[String].?, "senderReference".as[String].?, "createdFrom".as[String].?, "createdTo".as[String].?, "expand".as[String].?, "offset".as[Int].?(0), "limit".as[Int].?(10)) { (companyId, sendMode, documentType, senderReference, createdFrom, createdTo, expand, offset, limit) => 
            fileService.filesGet(companyId = companyId, sendMode = sendMode, documentType = documentType, senderReference = senderReference, createdFrom = createdFrom, createdTo = createdTo, expand = expand, offset = offset, limit = limit)
        }
      }
    } ~

In the code above, the query parameters createdFrom and createdTo should have the type OffsetDateTime.

Related issues/PRs

None found

Suggest a fix

The reason seems to be that in ScalaAkkaHttpServerCodegen.java->fromParameter (Line 294), param.dataType is always set to String for all non-primitive parameter types.

I'm new to openapi-generator so I can't really tell whether this is "by design". Perhaps since scala-akka-http-server is still in Beta, support for non-primitive data types in query parameters may not yet have been added?

Perhaps @Bouillie or @chameleon82 who seem to have been involved with creating this generator could shed some light on this? I'd be happy to contribute but would need some pointers on where to start in implementing this.

I'm also wondering what the current status of the scala-akka-http-server generator is. It seems to have been in beta for a while now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant