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

feat: add assert_operation_response, assert_raw_schema #545

Merged
merged 15 commits into from
Aug 23, 2023

Conversation

msutkowski
Copy link
Contributor

@msutkowski msutkowski commented Jun 8, 2023

This is a small proposal to add a few things to help with testing based on operationIds instead of (or along side of) schema_names. There are a few benefits to this, but the primary one is that it enforces operationId usage. Most organizations that deal with any type of code generation are going to most likely want to enforce operationIds.

I thought about just looking at the path in conn and resolving backwards with a method like assert_uses_schema, but that was a bit too 🪄 for what I wanted to achieve. (i was able to achieve this very simply by assigning the operation_id. it now supports automatic inference or manual specification)

I'm sure I've missed something here, but very open to feedback if anyone else would benefit from this 🎉

lib/open_api_spex/test/test_assertions.ex Outdated Show resolved Hide resolved
lib/open_api_spex.ex Show resolved Hide resolved
@msutkowski msutkowski requested a review from zorbash July 9, 2023 15:27
@duntonr
Copy link

duntonr commented Jul 12, 2023

This would really help in our case. Aside from operationIds, we define our spec file manually and put responses at #/components/responses/getFoo.

For JSON:API, this lets us define standard, top level attributes in the response, like type, id, links, etc and then ref to the attributes to its actual schema/model specific definition that lives at #/components/schemas/foo

@msutkowski msutkowski requested a review from zorbash August 22, 2023 21:15
@msutkowski
Copy link
Contributor Author

@zorbash Updated to address feedback, thanks!

@zorbash zorbash merged commit 7a0309a into open-api-spex:master Aug 23, 2023
@msutkowski msutkowski deleted the ms/operation-based-assertions branch August 23, 2023 15:47
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.

3 participants