-
Notifications
You must be signed in to change notification settings - Fork 352
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
use of __example observations #722
Comments
Hey @equalspeterd Sorry for the delay in the response!
This is correct, currently we only support body examples. Headers example is something we might want to support as well.
Can you clarify what's a documented profile? 🤔
This is a good point. Theoretically Prism has:
And the spec says that a 404 is when I guess we could |
Just a carefully crafted description in the prism README or such. Nothing special. If written in a manner that could be directly fork-lifted into the openAPI spec, that would go a long way towards moving the ball to fix the root cause (header & body named examples).
I appreciate you guys working on this. HT 🎩 to the team. |
@philsturgeon Thoughts? |
Yep Picking the example is for the Media Type examples, which do not have headers inside them. Headers are defined on the response object. Then inside there is This has an I just asked on the OpenAPI slack whilst writing this and yep @webron says it's a mistake!
So! I think your description document here is invalid, and this is not a mistake in Prism. I'll send a PR to the OpenAPI spec to fix up that invalid example now. Thanks for noticing this! |
@philsturgeon What about the 404 status code? |
@philsturgeon thanks for circling back with openAPI. I will take my proposal for supporting header/body paired response examples directly to them. I do think the |
@equalspeterd no problem! I get that 404 is not the most obvious thing, we agonised for ages over what to do. There are two schools of thought:
We picked 2 because if you are making bad requests we would like you to know about that, so you can fix your request. As for specifically 404, it could have been absolutely anything. It could have been a 500 because Prism as a server is unsure what to do, it could have been a 409 because the data source is unable to take this request in its current state, we could probably make a case for anything, but in the end we decided to push on and 404 is fine. |
Not sure if this is a bug or a feature request, so I will start here with a question/observation, and convert as appropriate.
selecting response examples
when using
?__example=foo
request parameters to select response examples, prism assumes that only a response object body is requested (as evidenced by the response error), and not examples defined elsewhere in the specification (e.g. headers):despite having defined:
(no
application/json
example namedmyHeaderExample
was defined in the response content).I totally understand the challenge here, as openAPI does no properly define a
response
object with anexamples
property. Rather, it relies on explicit parameter examples and media-type examples (and I don't see that changing anytime soon). However, a documented profile in prism could resolve this deficiency, when both a parameter named example and a media-type named example shared the same name, each could be used in constructing a response. Food for thought.The observation I had was why you choose to respond with a
404
if a named example is not found. That seems odd (to me at least). The resource was found, just not a suitable representation (the sought-after example). My €0.02.The text was updated successfully, but these errors were encountered: