Closed eaurele closed 5 years ago
cf REST API: Where to put parameters?
2 common ways seem to be in query string and in path:
The BCGov example showcases both:
Current implementation handles the first case by default, where a given parameter has "in": "query":
"in": "query"
"/names/search": { "get": { "parameters": [ { "name": "name", "in": "query", "example": "Victoria"
But doesn't handle "in": "path" and attempts to pass parameter in query string instead:
"in": "path"
"/features/{featureId}": { "get": { "parameters": [ { "name": "featureId", "in": "path", "example": 8879 } ],
bc_spec <- "https://raw.githubusercontent.com/bcgov/api-specs/master/bcgnws/bcgnws.json" bc_spec_path <- "bcgov_bcgnws.yaml" download.file(bc_spec, bc_spec_path) apipkgen::generate_pkg( "bcgov/", template_path = bc_spec_path ) #> Creating package 'bcgov' in '/tmp/Rtmp02qewm/reprex4680292a2879' devtools::install_local("bcgov", force = TRUE, quiet = TRUE) example_param_in_query <- bcgov::names_search(name = "Victoria", verbose = TRUE) example_param_in_path <- bcgov::features_featureId(featureId = 22474, verbose = TRUE) #> Error: Internal Server Error (HTTP 500)
standard output and standard error
trying URL 'https://raw.githubusercontent.com/bcgov/api-specs/master/bcgnws/bcgnws.json' Content type 'text/plain; charset=utf-8' length 73358 bytes (71 KB) ================================================== downloaded 71 KB * Trying 142.34.241.96... * TCP_NODELAY set * Connected to apps.gov.bc.ca (142.34.241.96) port 443 (#0) * ALPN, offering h2 * ALPN, offering http/1.1 * successfully set certificate verify locations: * CAfile: /etc/ssl/certs/ca-certificates.crt CApath: /etc/ssl/certs * SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384 * ALPN, server did not agree to a protocol * Server certificate: * subject: C=CA; ST=British Columbia; L=Victoria; O=Government of the Province of British Columbia; CN=*.apps.gov.bc.ca * start date: Sep 13 17:42:25 2018 GMT * expire date: Oct 8 18:12:24 2019 GMT * subjectAltName: host "apps.gov.bc.ca" matched cert's "apps.gov.bc.ca" * issuer: C=US; O=Entrust, Inc.; OU=See www.entrust.net/legal-terms; OU=(c) 2012 Entrust, Inc. - for authorized use only; CN=Entrust Certification Authority - L1K * SSL certificate verify ok. > GET /pub/bcgnws/names/search?outputFormat=json&name=Victoria HTTP/1.1 Host: apps.gov.bc.ca User-Agent: libcurl/7.58.0 r-curl/3.3 crul/0.7.0 Accept-Encoding: gzip, deflate Accept: application/json, text/xml, application/xml, */* < HTTP/1.1 200 OK < Date: Mon, 25 Feb 2019 14:14:23 GMT < Content-Type: application/json;charset=UTF-8 < Content-Disposition: inline; filename="results.json" < Cache-control: no-cache < Access-Control-Allow-Origin: * < Access-Control-Expose-Headers: Origin,Access-Control-Allow-Origin,Access-Control-Allow-Methods < Transfer-Encoding: chunked < * Connection #0 to host apps.gov.bc.ca left intact * Found bundle for host apps.gov.bc.ca: 0x56101fd930e0 [can pipeline] * Re-using existing connection! (#0) with host apps.gov.bc.ca * Connected to apps.gov.bc.ca (142.34.241.96) port 443 (#0) > GET /pub/bcgnws/features/{featureId}?featureId=22474 HTTP/1.1 Host: apps.gov.bc.ca User-Agent: libcurl/7.58.0 r-curl/3.3 crul/0.7.0 Accept-Encoding: gzip, deflate Accept: application/json, text/xml, application/xml, */* < HTTP/1.1 500 Internal Server Error < Date: Mon, 25 Feb 2019 14:14:23 GMT < Content-Type: text/html;charset=UTF-8 < Content-Length: 1038 < Cache-control: no-cache < Content-Language: en < Access-Control-Allow-Origin: * < Access-Control-Expose-Headers: Origin,Access-Control-Allow-Origin,Access-Control-Allow-Methods < Connection: close < * Closing connection 0 [WARNING] Could not parse YAML metadata at line 13 column 1: :7:21: Unexpected ' '
Created on 2019-02-25 by the reprex package (v0.2.1)
thanks @eaurele for this. agreed it doens't support path right now. will look into it
@eaurele reinstall and try again, should work now for bcgov eg, havne't tested with any others yet
cf REST API: Where to put parameters?
2 common ways seem to be in query string and in path:
The BCGov example showcases both:
Current implementation handles the first case by default, where a given parameter has
"in": "query"
:But doesn't handle
"in": "path"
and attempts to pass parameter in query string instead:standard output and standard error
Created on 2019-02-25 by the reprex package (v0.2.1)