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

Fix incorrect placement of header=present in versions endpoint #419

Merged
merged 3 commits into from Jul 21, 2020

Conversation

ml-evs
Copy link
Member

@ml-evs ml-evs commented Jul 20, 2020

Closes #418

@ml-evs ml-evs requested a review from CasperWA July 20, 2020 14:45
@ml-evs
Copy link
Member Author

ml-evs commented Jul 20, 2020

Hmmm, I don't like that this changes the OpenAPI schemas, perhaps there is a way smarter way to pass these kind of parameters.

@ml-evs
Copy link
Member Author

ml-evs commented Jul 20, 2020

Hmmm, I don't like that this changes the OpenAPI schemas, perhaps there is a way smarter way to pass these kind of parameters.

Okay, replaced it with a slightly gross hack, think it should be stable enough.

@codecov
Copy link

codecov bot commented Jul 20, 2020

Codecov Report

Merging #419 into master will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #419   +/-   ##
=======================================
  Coverage   90.99%   90.99%           
=======================================
  Files          55       55           
  Lines        2522     2522           
=======================================
  Hits         2295     2295           
  Misses        227      227           
Flag Coverage Δ
#unittests 90.99% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
optimade/server/routers/versions.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d8443d6...ca28a84. Read the comment docs.

Copy link
Member

@CasperWA CasperWA left a comment

Choose a reason for hiding this comment

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

I was just about to suggest the option you went for in the initial commit.

I will just ping @rartino, @merkys and @sauliusg on their opinion on whether the headers MIME type parameter should be added to the OpenAPI response type value or not.

optimade/server/routers/versions.py Outdated Show resolved Hide resolved
@sauliusg
Copy link

I will just ping @rartino, @merkys and @sauliusg on their opinion on whether the headers MIME type parameter should be added to the OpenAPI response type value or not.

I would say yes, headers=present should be added, since our OPTIMADE specs mandate that header MUST always be present (to be future-proof), and RFC 4180 says "the presence or absence of the header line should be indicated via the optional "header" parameter of this MIME type".

@rartino
Copy link
Contributor

rartino commented Jul 20, 2020

I agree with @sauliusg, the most correct thing to do is to include header=present. Technically I don't think leaving it out is a strict violation of RFC 4180, but it certainly is better to include it. However, note the singular header not headers.

@ml-evs
Copy link
Member Author

ml-evs commented Jul 20, 2020

I agree with @sauliusg, the most correct thing to do is to include header=present. Technically I don't think leaving it out is a strict violation of RFC 4180, but it certainly is better to include it. However, note the singular header not headers.

Just to clarify, we will definitely include it in the response (and even in the correct place this time), it's just whether it should be included in the OpenAPI schema, which would look like this:

"content": {
    "text/csv; header=present": {
        "schema": {
            "type": "string"
        }
}

This looks a bit funny to me, but I'm not sure of any other way of doing it. This also excludes the other parameter charset=utf-8 that gets added to the Content-Type in a response.

@CasperWA
Copy link
Member

I think, let's add it to the OpenAPI as well. Being explicit.
While the charset parameter is not added, the header parameter is much more CSV-specific, and hence I think it's fine to not include charset, while including header.

@ml-evs
Copy link
Member Author

ml-evs commented Jul 21, 2020

I think, let's add it to the OpenAPI as well. Being explicit.
While the charset parameter is not added, the header parameter is much more CSV-specific, and hence I think it's fine to not include charset, while including header.

Fair enough, it certainly makes the fix easier!

@ml-evs ml-evs requested a review from CasperWA July 21, 2020 13:03
Copy link
Member

@CasperWA CasperWA left a comment

Choose a reason for hiding this comment

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

Great catch with this one @ml-evs !

@ml-evs ml-evs merged commit 07d4d01 into master Jul 21, 2020
@ml-evs ml-evs deleted the ml-evs/fix_#418 branch July 21, 2020 13:46
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.

/versions endpoint content-type parameter "header=present" is provided in the wrong place
4 participants