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

RESTWS-649 - Correct host property in OpenAPI Spec #302

Merged
merged 1 commit into from Sep 21, 2017

Conversation

gayanW
Copy link
Member

@gayanW gayanW commented Sep 15, 2017

  • Make host and basePath not mandatory in SwaggerSpecificationCreator
  • Set host and basePath to correct values in SwaggerSpecificationController

Issue: https://issues.openmrs.org/browse/RESTWS-649

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 40.482% when pulling 54d548d on gayanW:RESTWS-649 into 4563334 on openmrs:master.

String resourceName, String searchHandlerId, int queryIndex) {
List<org.openmrs.module.webservices.docs.swagger.Parameter> parameters = new ArrayList<org.openmrs.module.webservices.docs.swagger.Parameter>();
String resourceURL = getResourceUrl(getBaseUrl(), resourceName);
for (SearchHandlerDoc searchDoc : searchHandlerDocs) {
Copy link
Member

Choose a reason for hiding this comment

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

Is removing this block of code related to? "Correct host property in OpenAPI Spec"

Copy link
Member Author

Choose a reason for hiding this comment

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

See the comment above.

@@ -87,10 +86,27 @@

private Logger log = Logger.getLogger(this.getClass());

public SwaggerSpecificationCreator(String baseUrl) {
this.baseUrl = baseUrl;
Copy link
Member

Choose a reason for hiding this comment

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

Is removing the lines below related to? "Correct host property in OpenAPI Spec"

Copy link
Member Author

Choose a reason for hiding this comment

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

We no longer use the baseUrl constructor. However the searchHandlerDocs instance variable requires baseUrl param to initiate. searchHandlerDocs is only referenced by getParametersListForSearchHandlers() which is unused. So it makes sense to remove these here.

Copy link
Member

Choose a reason for hiding this comment

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

I do not refute the fact that we no longer need some code. What am simply saying is that if removing it is not related to "Correct host property in OpenAPI Spec", then it should be in a separate pull request.

@dkayiwa
Copy link
Member

dkayiwa commented Sep 17, 2017

@gayanW this pull request seems to have more changes that needed for just "Correct host property in OpenAPI Spec". Can you create a separate pull request for other things instead of including them all in this?

@gayanW
Copy link
Member Author

gayanW commented Sep 20, 2017

Please see now. baseUrl was being used to generate the host, basePath, and scheme. Yet the logic there was invalid. So it needs to be removed.

Now in the controller we pass the accurate values.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.06%) to 40.395% when pulling b110809 on gayanW:RESTWS-649 into 4563334 on openmrs:master.

@dkayiwa
Copy link
Member

dkayiwa commented Sep 20, 2017

@gayanW do you mind squashing the commits?

* Make host and basePath not mandatory in SwaggerSpecificationCreator
* Set host and basePath to correct values in  SwaggerSpecificationController
@coveralls
Copy link

Coverage Status

Coverage increased (+0.06%) to 40.395% when pulling 016e643 on gayanW:RESTWS-649 into 4563334 on openmrs:master.

@gayanW
Copy link
Member Author

gayanW commented Sep 21, 2017

Done.


baseUrl.append(scheme); // http, https
baseUrl.append("://");
baseUrl.append(request.getServerName());
Copy link
Member

Choose a reason for hiding this comment

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

Does this ticket involve removing all these lines of code (from line 30 - 68)?
Are you sure we are not having any regressions here?

else if (scheme.equals("https"))
urlWithoutScheme = resourcesUrl.replace("https://", "");

SwaggerSpecificationCreator creator = new SwaggerSpecificationCreator(urlWithoutScheme);
Copy link
Member Author

Choose a reason for hiding this comment

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

All this logic does nothing but build the baseUrl (urlWithoutScheme) string and then pass it to the SwaggerSpecificationCreator(..). As noted before generated string was invalid. Thus results in invalid host, and basePath in the spec. No there's no regression.

@dkayiwa dkayiwa merged commit bba5380 into openmrs:master Sep 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants