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

Scala codegen doesn't work with openapi petstore.yml #1740

Open
er1c opened this issue May 23, 2023 · 1 comment
Open

Scala codegen doesn't work with openapi petstore.yml #1740

er1c opened this issue May 23, 2023 · 1 comment

Comments

@er1c
Copy link

er1c commented May 23, 2023

Using petstore.yml: https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml and https://github.com/guardrail-dev/guardrail-sample-sbt-http4s

  /user:
    post:
      tags:
        - user
      summary: Create user
      description: This can only be done by the logged in user.
      operationId: createUser
      responses:
        default:
          description: successful operation

works:

  /user:
    post:
      tags:
        - user
      summary: Create user
      description: This can only be done by the logged in user.
      operationId: createUser
      responses:
        '200':
          description: successful operation
[IJ]clean; compile
[success] Total time: 1 s, completed May 23, 2023, 4:15:32 PM
[warn] There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings.
Error:Unknown HTTP status code: default
[error] (Compile / guardrail) dev.guardrail.sbt.CodegenFailedException
[error] Total time: 0 s, completed May 23, 2023, 4:15:33 PM

Then that unlocked a new error:

[error] /Users/ericpeters/even/play/guardrail-sample-sbt-http4s/src/main/scala/Server.scala:59:105: value Accepted is not a member of object example.server.store.StoreResource.DeleteOrderResponse
[error]         val out = m.get(orderId).fold[StoreResource.DeleteOrderResponse](respond.NotFound)(_ => respond.Accepted)
[error]                                                                                                         ^
[error] /Users/ericpeters/even/play/guardrail-sample-sbt-http4s/target/scala-2.13/src_managed/main/example/server/pet/Routes.scala:175:119: not found: value utf8
[error]             for (additionalMetadata <- multipart.parts.find(_.name.contains("additionalMetadata")).map(_.body.through(utf8.decode).compile.foldMonoid).sequence; response <- handler.uploadFile(UploadFileResponse)(petId, additionalMetadata, multipart.parts.find(_.name.contains("file")).map(_.body)) flatMap ({
[error]                                                                                                                       ^
[error] two errors found
@blast-hardcheese
Copy link
Member

The utf8 and Multiparts issue is new, thanks for reporting! I've resolved that issue in the sample repo.

The default issue is unfortunate, since it's incorrect to assume that 100 and 500 have the same semantics.

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

No branches or pull requests

2 participants