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

Remove servers urls with trailing slash #7940

Merged
merged 9 commits into from
Jan 25, 2021
Merged

Remove servers urls with trailing slash #7940

merged 9 commits into from
Jan 25, 2021

Conversation

ksvirkou-hubspot
Copy link
Contributor

@ksvirkou-hubspot ksvirkou-hubspot commented Nov 14, 2020

Fixed issue #7533
I see it in every language

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • If contributing template-only or documentation-only changes which will change sample output, build the project beforehand.
  • Run the shell script ./bin/generate-samples.shto update all Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master. These must match the expectations made by your contribution. You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*. For Windows users, please run the script in Git BASH.
  • File the PR against the correct branch: master
  • Copy the technical committee to review the pull request if your PR is targeting a particular programming language.

@ksvirkou-hubspot
Copy link
Contributor Author

ksvirkou-hubspot commented Nov 14, 2020

Hi everyone
Could you take a look?
cc: @wing328 @spacether

@ksvirkou-hubspot
Copy link
Contributor Author

Hi everyone
Could you take a look?
thank you in advance
cc: @wing328 @taxpon @frol @mbohlool @cbornet @kenjones-cisco @tomplus @Jyhess @arun-nalla @spacether @jimschubert @ackintosh @jmini @etherealjoy

@atanasiuk-hubspot
Copy link
Contributor

Any updates on this?

@yfaktor
Copy link

yfaktor commented Nov 27, 2020

Hi - this is holding back our major release, if you could be so kind to give this PR some love it would be greatly appreciated. Thanks!

@spacether
Copy link
Contributor

Can you please add tests showing this code working for the use cases that you are concerned about?

@wing328 wing328 added this to the 5.0.0 milestone Dec 8, 2020
@wing328 wing328 modified the milestones: 5.0.0, 5.0.1 Dec 21, 2020
@ksvirkou-hubspot
Copy link
Contributor Author

I ve just added test
Could you check it ?

cc @wing328 @spacether

@yfaktor
Copy link

yfaktor commented Jan 5, 2021

Hi - I was wondering if we could get a ship on this - we are pretty behind on the release and any help would be greatly appreciated. Thanks so much in advance!

@spacether
Copy link
Contributor

Closing an re-opening to kick off CI tests.

@spacether
Copy link
Contributor

spacether commented Jan 6, 2021

@ksvirkou-hubspot there is a CI error here: Please run 'bin/utils/ensure-up-to-date' locally and commit changes (UNCOMMITTED CHANGES ERROR) Can you fix it? We can't merge it until all tests pass.

@spacether
Copy link
Contributor

I updated the test to be in the java layer as this change impacts all generators

url: https://www.apache.org/licenses/LICENSE-2.0.html
version: 1.0.0
servers:
- url: /
Copy link
Contributor

@spacether spacether Jan 11, 2021

Choose a reason for hiding this comment

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

Per @jimschubert
Server with no url base specified is meant to be the same server where the spec doc was downloaded from.
https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#server-object:
REQUIRED. A URL to the target host. This URL supports Server Variables and MAY be relative, to indicate that the host location is relative to the location where the OpenAPI document is being served. Variable substitutions will be made when a variable is named in {brackets}.
So we should only do this stripping if the length is > 1

Copy link
Contributor

@spacether spacether Jan 12, 2021

Choose a reason for hiding this comment

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

Hmm when we keep this value as '/' rust tests fail because they assume that we keep stripping the / from the end of the server url. Probably better to keep removing it and have future PRs detect the "" use case if they need to. That way this is non-breaking.

@spacether
Copy link
Contributor

Closing and re-opening for travis

@spacether spacether closed this Jan 15, 2021
@spacether spacether reopened this Jan 15, 2021
@ksvirkou-hubspot
Copy link
Contributor Author

ksvirkou-hubspot commented Jan 20, 2021

 Hey everyone
 In my opinion it is really important fix for the latest version of the generator
 We noticed this problem in ruby too
 ping me if I can help you with it
 CC @spacether

@spacether
Copy link
Contributor

Closing and re-opening for travis

@spacether spacether closed this Jan 20, 2021
@spacether spacether reopened this Jan 20, 2021
@spacether
Copy link
Contributor

@ksvirkou-hubspot can you help get tests passing?
@wing328 I see this change in java jersey-2:

--- a/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/ApiClient.java
+++ b/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/ApiClient.java
@@ -72,7 +72,7 @@ public class ApiClient extends JavaTimeFormatter {
 
   protected List<ServerConfiguration> servers = new ArrayList<ServerConfiguration>(Arrays.asList(
     new ServerConfiguration(
-      "/",
+      "",
       "No description provided",
       new HashMap<String, ServerVariable>()
     )
Perform git status
On branch pull/7940
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)

Are you okay with it?
If no then

@@ -1483,4 +1484,8 @@ private void generateFilesMetadata(List<File> files) {
}
}

private String removeTrailingSlash(String value) {
Copy link
Contributor

@spacether spacether Jan 20, 2021

Choose a reason for hiding this comment

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

Maybe we should pass in a boolean doNotModifyOnlySlash and when it is true, for "/" leave it as-is?
That we we could use it to preserve the current behavior here for rust jersey-2 etc.

@wing328
Copy link
Member

wing328 commented Jan 25, 2021

cc @OpenAPITools/generator-core-team as there are changes to the default generator

@wing328 wing328 changed the title it handles servers urls with trailing slash Remove servers urls with trailing slash Jan 25, 2021
@wing328 wing328 merged commit 57227e5 into OpenAPITools:master Jan 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants