prism
prism copied to clipboard
Consider falling back to a statically generated response when no example key exists from Prefer header
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
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).
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?
Released in 5.8.2.