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

Consider falling back to a statically generated response when no example key exists from Prefer header #2381

Open
louzena-inshur opened this issue Sep 7, 2023 · 2 comments

Comments

@louzena-inshur
Copy link

If you pass a Prefer header with an example key, and that key does not exist, then Prism returns an error

Request terminated with error: https://stoplight.io/prism/errors#NOT_FOUND: The server cannot find the requested content

It would be useful for Prism to fallback to static generation (or dynamic if set) if this happens instead of throwing an error.

Context

We are using Prefer headers to control the examples that we deliver, but don't necessarily need examples for every endpoint. It would be nice to still send the Prefer header key, but fallback to static generation if it doesn't exist

@daniel-white
Copy link
Member

thanks for the issue @louzena-inshur. we are reluctant to implement this as it could cause unexpected behavior in the case of typos or other bad configuration. we find it important that the client is aware of this mismatch. we would take a PR to improve the response error message (and status code).

@louzena-inshur
Copy link
Author

Thanks @daniel-white , that makes sense with improving the response error message and that you'd want to be explicit if a keyed example was not found.

Perhaps one to think about - having an argument on the CLI for fallbacks like this. Could fallback to a singular 'example' if it exists, when an argument is set?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants