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

Fix parsing no content into null instead of 'null' #911

Merged
merged 1 commit into from
Nov 5, 2024

Conversation

olivernybroe
Copy link
Contributor

@olivernybroe olivernybroe commented Nov 1, 2024

Hello 👋
Thank you for the package, we are really enjoying all the work you put into it. I hope you will accept this small change which we think might be a bug :)

Problem

When having a response with no content in it, it ends up showing as plaintext in openapi spec.

#[Response(status: 404, description: 'Organization not found')]

Will be generated as

        404:
          description: 'Organization not found'
          content:
            text/plain:
              schema:
                type: string
                example: 'null'

solution

To fix this problem, we make sure that if the content is null, we pass null forward when converting the attribute to an array. Previously the null value was passed through json_encode which will convert it into 'null'.

After this solution, we end up with

        404:
          description: 'Organization not found'
          content:
            application/json:
              schema:
                type: object
                nullable: true

@shalvah
Copy link
Contributor

shalvah commented Nov 5, 2024

Good catch, thanks!

@shalvah shalvah merged commit 6837c03 into knuckleswtf:master Nov 5, 2024
6 checks passed
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

Successfully merging this pull request may close these issues.

2 participants