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

FI-2494 POST capability added to granular scopes #158

Merged
merged 9 commits into from
Mar 7, 2024

Conversation

360dgries
Copy link
Contributor

Summary

Added inspection of request body if it is a POST request for query parameters.

Wondering about if we will ever expect more in the body than query parameters, i.e. should there be more thorough parsing/decision making here?

Also want to check that POST searches are made to an endpoint that ends in \_search every time? The current spec test uses that endpoint, and I don't think it would impact the functionality, but the spec test wouldn't pass until I added that into the url (fhir_search must automatically add the route when it sees it's a POST?)

Testing Guidance

Added a spec test that stubs a post request and returns correct resources, and expects test to pass.

@360dgries 360dgries requested a review from Jammjammjamm March 6, 2024 17:10
search_method = previous_request.verb.to_sym
params = search_method == :get ? previous_request.query_parameters : JSON.parse(previous_request.request_body)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The body of a POST search is application/x-www-form-urlencoded not JSON.

http://hl7.org/fhir/R4/search.html#Introduction

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, changed both the rspec test to encode it as such and the parsing here to treat it as application/x-www-form-urlencoded instead of json.

@360dgries 360dgries requested a review from Jammjammjamm March 6, 2024 17:29
@@ -133,6 +133,7 @@ def self.metadata
).to_json
)
end

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove extra whitespace.

search_method = previous_request.verb.to_sym
params = search_method == :get ? previous_request.query_parameters : Hash[URI.decode_www_form(previous_request.request_body)]
binding.pry if search_method == :post
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove pry.


it 'correctly pulls parameters from POST body' do
response_body =
FHIR::Bundle.new(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent this.

@360dgries 360dgries requested a review from Jammjammjamm March 7, 2024 16:28
@360dgries 360dgries merged commit 3ab3ffb into main Mar 7, 2024
2 checks passed
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.

2 participants