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: handling letter cases when merging http ops #83

Merged
merged 2 commits into from
Mar 9, 2020

Conversation

karol-maciaszek
Copy link
Contributor

Case insensitive comparison of header/mediaType/server.url when merging.

src/merge.ts Outdated
@@ -20,12 +20,12 @@ export const mergeResponses = mergeLists<IHttpOperationResponse>(
);

const mergeServers = mergeLists<IServer>(
(s1, s2) => s1.url === s2.url,
(s1, s2) => s1.url.toLowerCase() === s2.url.toLowerCase(),
Copy link
Contributor

@XVincentX XVincentX Mar 6, 2020

Choose a reason for hiding this comment

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

This is interesting, I do not know whether we should do this or not. urls are not case insensitive and some server do discriminate based on them. @marbemac @lottamus

I would say we should consider casing in URLs.

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually @philsturgeon you could give your idea on this too.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don’t know how many people are doing this in the wild but yeah technically they could. Let’s leave this out and see if it’s reported, either by reports we can run or by users.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just removed it.

I believe we should have it like that: case-insensitive host and case-sensitive path. WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree, HOSTS should be case insensitive. It this URL a full one (comprehensive of the host)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, that is even funnier. See the typings: https://github.com/stoplightio/types/blob/master/src/servers.ts#L8

We can have variables inside the server URL. I'll check this out, but it seems that we need to parse the URL in order to understand what is case-(in)?sensitive.

  1. host name is case-insensitive
  2. URL is case-sensitive
  3. variable name: I can't find in OAS spec whether this is case sensitive or not, but I would assume it is

Now the funny part: a variable inside hostname makes it partially case-sensitive.

I guess we need to address it now or create an issue to address it later. Actually I'm also thinking about http-spec being responsible for server.url sanitization while transforming from different spec formats.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah let's make a separate issue for this, we can get this over the finish line. Feel free to open an issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here is the task: #84

@XVincentX XVincentX merged commit 51925ec into master Mar 9, 2020
@XVincentX XVincentX deleted the fix/httpop-merge-letter-case-fix branch March 9, 2020 12:48
@stoplight-bot
Copy link
Collaborator

🎉 This PR is included in version 2.8.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

4 participants