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!: support $ref from endpoint response to components/responses #1148

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

eli-bl
Copy link
Collaborator

@eli-bl eli-bl commented Oct 24, 2024

Fixes #1125.

This makes it so the following—

components:
  responses:
    GoodResponse:
      description: OK
      content:
        "application/json":
          schema:
            $ref: "#/components/schemas/MyObject"

paths:
  "/endpoint":
    get:
      responses:
        "200":
          $ref: "#/components/responses/GoodResponse"

—is exactly equivalent to:

paths:
  "/endpoint":
    get:
      responses:
        "200":
          description: OK
          content:
            "application/json":
              schema:
                $ref: "#/components/schemas/MyObject"

Previously, it would have failed to follow the response reference and behaved as if the response had no content.

This still requires the response to be fully defined inline in components/responses; it can't itself consist of just a $ref.

dbanty
dbanty previously approved these changes Oct 27, 2024
Copy link
Collaborator

@dbanty dbanty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Will include as a breaking change, since documents which previously generated (even though the responses would be empty) may stop generating.

@dbanty dbanty added the 🥚breaking This change breaks compatibility label Oct 27, 2024
@dbanty dbanty changed the title fix: support $ref from endpoint response to components/responses fix!: support $ref from endpoint response to components/responses Oct 27, 2024
@eli-bl
Copy link
Collaborator Author

eli-bl commented Oct 28, 2024

@dbanty:

Looks good to me! Will include as a breaking change, since documents which previously generated (even though the responses would be empty) may stop generating.

You mean they would stop generating if there was an invalid response in the spec? Is it always the policy for this project that "it used to incorrectly pass when you used an invalid spec (even though the generated code wouldn't actually work), now it errors out" would constitute a breaking change rather than a bugfix or feature addition?

@eli-bl eli-bl requested a review from dbanty October 28, 2024 19:24
@eli-bl eli-bl closed this Oct 29, 2024
@eli-bl eli-bl deleted the responses-by-ref branch October 29, 2024 22:21
@eli-bl eli-bl restored the responses-by-ref branch October 29, 2024 22:21
@eli-bl eli-bl reopened this Oct 29, 2024
@eli-bl
Copy link
Collaborator Author

eli-bl commented Oct 29, 2024

(Sorry, deleted the branch by total stupid accident)

@eli-bl eli-bl closed this Nov 20, 2024
@eli-bl eli-bl deleted the responses-by-ref branch November 20, 2024 23:29
@eli-bl eli-bl restored the responses-by-ref branch November 20, 2024 23:30
@squat
Copy link

squat commented Dec 6, 2024

@eli-bl any chance you would re-open this PR to try merging again? The lack of this basic OpenAPI functionality is a big gap in the project.

@eli-bl eli-bl reopened this Dec 7, 2024
@eli-bl
Copy link
Collaborator Author

eli-bl commented Dec 7, 2024

@squat Thanks for reminding me - I had closed this by accident earlier, then I saw that I needed to resolve conflicts due to other changes in the meantime, now I've resolved them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🥚breaking This change breaks compatibility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect generation of _parse_response
3 participants