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][Haskell]Faulty generation for responses with no content #9829

Closed
5 of 6 tasks
mgajda opened this issue Jun 22, 2021 · 0 comments · Fixed by #9830
Closed
5 of 6 tasks

[BUG][Haskell]Faulty generation for responses with no content #9829

mgajda opened this issue Jun 22, 2021 · 0 comments · Fixed by #9830

Comments

@mgajda
Copy link
Contributor

mgajda commented Jun 22, 2021

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

All responses are assumed to have non-empty content, and generated Haskell code tries to parse the missing response body.
This makes responses with no body non-functional.

openapi-generator version

Git commit: 77e1ca56cf329bfb22b05f853587263fd0ff6503 (June 16th 2021)
Version in pom.xml is 5.2.0-SNAPSHOT.

OpenAPI declaration file content or url

Here is an example input spec:

openapi: 3.0.0
info:
  description: Minimal failing example
  version: "1.0.0"
  title: Minimal API
  contact:
    email: [email protected]

paths:
  /session:
    post:
      summary: start session
      operationId: startSession
      responses:
        '201':
          description: session created
       '404':
          description: service offline
Generation Details

This will generate API that declares JSON object on the output:

type MinimalAPI                                                                                                                                                           
    =    "session" :> Verb 'POST 200 '[JSON] () -- 'startSession' route                                                                                    
    :<|> Raw

This suggests that we have a content that conforms to InlineResponse201.
Attempt to use this endpoint when fail when trying to parse missing response body.

Steps to reproduce

Copy paste spec.yaml above and run:

openapi-generator-cli generate -i spec.yaml  -g haskell
Suggest a fix

This change of the generated code works:

type MinimalAPI                                                                                                                                                           
    =    "session" :> Verb 'POST 204 '[JSON] NoContent -- 'startSession' route                                                                                    
    :<|> Raw
@mgajda mgajda changed the title [BUG] Haskell is faulty for responses with no content [BUG][Haskell]Faulty generation for responses with no content Jun 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant