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: ensure operation_id is always set on conn.private #606

Merged
merged 2 commits into from
May 15, 2024

Conversation

msutkowski
Copy link
Contributor

@msutkowski msutkowski commented May 13, 2024

There was an issue where you had to pass in the operationId on error cases to assert_operation_response because of the nature of the error handling halting and returning a collection of errors for the given step. Lifting the put_operation_id up gets around all of that as even if things halt, we'll still have a reference to the operationId in conn.private

@@ -78,6 +78,7 @@ defmodule OpenApiSpex.Plug.CastAndValidate do
) do
{spec, operation_lookup} = PutApiSpec.get_spec_and_operation_lookup(conn)
operation = operation_lookup[operation_id]
conn = put_operation_id(conn, operation)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was getting dropped when an error during casting occurred. Even though we set it, the error handling returned a stale conn so it wouldn't pass through. Lifting this up top ensures that it's always there for all success/error cases.

@msutkowski msutkowski changed the title fix: ensure operation_id is always set on conn.private when an operat… fix: ensure operation_id is always set on conn.private May 13, 2024
@mbuhot
Copy link
Collaborator

mbuhot commented May 15, 2024

Thanks @msutkowski !

@mbuhot mbuhot merged commit 3f54e57 into open-api-spex:master May 15, 2024
14 checks passed
@msutkowski msutkowski deleted the ms/fix-operation_id branch May 15, 2024 21:56
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.

None yet

2 participants