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

Disable XML and HTML responses from current registry-api-service implementation #91

Closed
jordanpadams opened this issue Jun 29, 2021 · 7 comments
Assignees
Labels

Comments

@jordanpadams
Copy link
Member

jordanpadams commented Jun 29, 2021

Motivation

...so that I no longer allow responses from response formats that have not yet been sufficiently designed/implemented.

Additional Details

Acceptance Criteria

Given a deployed registry-api-service with data ingested
When I perform a query of the API from a browser (e.g. https://pds-gamma.jpl.nasa.gov/api/products)
Then I expect the response will be an error message indicating XML/HTML is not supported

Engineering Details

Note: If this is not possible, I would like us to disable the XML response format until NASA-PDS/registry-api#456 is implemented. Most of our users will use the swagger page for initial testing, and we need to limit how much visibility comes to that response format until it is in a mort robust state.

@jordanpadams jordanpadams added requirement the current issue is a requirement needs:triage labels Jun 29, 2021
@jordanpadams jordanpadams changed the title As an API user, I want the default response format to be JSON As an API user, I want the default response format from a browser to be JSON Jun 29, 2021
@jordanpadams jordanpadams added this to the 10.Lynn.Jennings milestone Jun 29, 2021
@jordanpadams
Copy link
Member Author

Update engineering details on this ticket:

Note: If this is not possible, I would like us to disable the XML response format until NASA-PDS/registry-api#456 is implemented. Most of our users will use the swagger page for initial testing, and we need to limit how much visibility comes to that response format until it is in a mort robust state.

@al-niessner
Copy link
Contributor

al-niessner commented Aug 4, 2021

@jordanpadams @tloubrieu-jpl

The two URLs in the accept give me 404 errors (used my local registry-api-service with one of them but fails the same as pds.nasa.gov version):

$ curl -X GET "http://localhost:8080/api/products"
{"timestamp":1628103468072,"status":404,"error":"Not Found","message":"","path":"/api/products"}
$ curl -X GET "https://pds.nasa.gov/api/swagger-ui.html"
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL was not found on this server.</p>
</body></html>

@tloubrieu-jpl
Copy link
Member

Hi @al-niessner ,

I updated the url in the ticket description. sorry about that.

@tloubrieu-jpl
Copy link
Member

@al-niessner

Just to make sure we share the same understanding of the ticket, the request with curl already returns json format, it is the default from the server point of view.

The issue is that the browser (google chorme), sets a default accept to application/html and the server believes the best fit is application/xml whereas we want to return application/json. Maybe for that case, we shoud just accept application/html and return json. That will be defined from this section of the code https://github.com/NASA-PDS/registry-api-service/blob/45798b880a7229e4923f85e2d25e4ee0c59bae1d/src/main/java/gov/nasa/pds/api/engineering/configuration/WebMVCConfig.java#L89

For the swagger ui, I have no idea how to change that but there might be a configuration that you will find.

thanks,

@al-niessner
Copy link
Contributor

@tloubrieu-jpl

Is this a registry-api-service thing? When I do it locally (http://localhost:8080/api/products) it returns 404 with this error in the registry-api-service:

2021-08-04 19:14:06.823 DEBUG 58 --- [0.3-8080-exec-8] o.s.web.servlet.DispatcherServlet        : GET "/api/products", parameters={}
2021-08-04 19:14:06.823 DEBUG 58 --- [0.3-8080-exec-8] pertySourcedRequestMappingHandlerMapping : looking up handler for path: /api/products
2021-08-04 19:14:06.824  WARN 58 --- [0.3-8080-exec-8] o.s.web.servlet.PageNotFound             : No mapping for GET /api/products
2021-08-04 19:14:06.824 DEBUG 58 --- [0.3-8080-exec-8] o.s.web.servlet.DispatcherServlet        : Completed 404 NOT_FOUND

@tloubrieu-jpl
Copy link
Member

Hi @al-niessner
When on a dev environment, you should remove /api (the /api is part of the base url on pds-gamma, through an apache reverse proxy).
So url http://localhost:8080/products shoud work in your dev environement.

@jordanpadams jordanpadams changed the title As an API user, I want the default response format from a browser to be JSON Disable XML and HTML responses from current registry-api-service implementation Aug 26, 2021
@jordanpadams jordanpadams added enhancement New feature or request and removed requirement the current issue is a requirement labels Aug 26, 2021
@jordanpadams
Copy link
Member Author

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

No branches or pull requests

3 participants