Skip to content

Use request's host in error result's absoluteKeywordLocation #30

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

Closed
karenetheridge opened this issue Jan 30, 2022 · 1 comment
Closed

Comments

@karenetheridge
Copy link
Owner

If the openapi document is constructed with a relative URI as its identifier, there is an opportunity to resolve this URI at runtime when generating errors so the stated location of the document uses the same host as that used in the original request, so the caller has an absolute URI as a reference for the document used to generate the error.

  • JSM::evaluate() needs to accept a base_uri at runtime, as a config_override (3rd argument)
  • capture $request->uri->host when $request and $response initializes its $state, and pass this value to JSM::evaluate

'servers' information in the document should be taken into account, e.g.:

  • servers: specifies a base uri of "/v1"
  • path-item: specifies an operation with path "/foo/bar"
  • openapi document is configured with a canonical uri of "/api"

therefore an incoming request with uri "http://example.com/v1/foo/bar" is routed to this operation, and errors will use absoluteKeywordLocation: "http://example.com/v1/api#/path/to/error"

@karenetheridge
Copy link
Owner Author

This is now done (except for looking at the servers config) in 0.021.

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

No branches or pull requests

1 participant