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

Add new 'use_spec_url_for_base_path' boolean config option #300

Merged

Conversation

DStape
Copy link
Contributor

@DStape DStape commented Sep 21, 2018

This new option addresses issues arising from 'basePath' not being
present in a given spec.

According to the 2.0 spec, "If it is not included, the API is served directly
under the host. The value MUST start with a leading slash (/).".

1083636 made the SwaggerClient compliant with the spec (basePath is now
implicitly set to '/' if field is missing from spec). However, this broke
existing code that utilizes the SwaggerClient (see Issue #299).

The current (spec-compliant) behaviour remains with this new option as
it defaults to False. Overriding this default with 'True' means the path
element of the URL used to retrieve the spec will be used instead.

@DStape
Copy link
Contributor Author

DStape commented Sep 21, 2018

UTs still to be updated, but I'd like some feedback first before spending time on those, just to make sure I'm not doing anything that's obviously silly, thanks.

@coveralls
Copy link

coveralls commented Sep 21, 2018

Coverage Status

Coverage increased (+0.006%) to 98.333% when pulling 7e7b974 on DStape:fix-basePath-used-to-build-api-url-#299 into db42ca2 on Yelp:master.

@DStape
Copy link
Contributor Author

DStape commented Sep 27, 2018

Hello @macisamuele, @sjaensch, are you able to provide any feedback on this? Thanks

@DStape
Copy link
Contributor Author

DStape commented Oct 10, 2018

Gentle bump - @macisamuele , @sjaensch

Copy link
Collaborator

@macisamuele macisamuele left a comment

Choose a reason for hiding this comment

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

I'm not a big fan of adding configuration parameters that modify the behaviour respect what the official specs.
Anyway checking the threads seems like an approach like this could help with supporting additional use-cases without adding tons of complexity on the configuration understanding and processing.

So overall I'm OK with the approach.

Please make sure to address the opened issue and to create a test to verify that the configured value is used and not used according to the presence of basePath in the swagger specs.

bravado_core/spec.py Outdated Show resolved Hide resolved
@DStape DStape force-pushed the fix-basePath-used-to-build-api-url-#299 branch from 38be785 to 43efb90 Compare November 5, 2018 22:56
@DStape
Copy link
Contributor Author

DStape commented Nov 5, 2018

Updated the doc string and added new tests.

This new option addresses issues arising from 'basePath' not being
present in a given spec.

According to the 2.0 spec, "If it is not included, the API is served directly
under the host. The value MUST start with a leading slash (/)".

1083636 made the SwaggerClient compliant with the spec (basePath is now
implicitly set to '/' if field is missing from spec). However, this broke
existing code that utilizes the SwaggerClient (see Issue Yelp#299).

The current (spec-compliant) behaviour remains with this new option as
it defaults to False. Overriding this default with 'True' means the path
element of the URL used to retrieve the spec will be used instead.
@DStape DStape force-pushed the fix-basePath-used-to-build-api-url-#299 branch from 43efb90 to 7e7b974 Compare November 6, 2018 11:28
@DStape
Copy link
Contributor Author

DStape commented Nov 6, 2018

Fixed failing python3 test (due to urllib differences between python 2 and 3).

@macisamuele macisamuele merged commit baaef12 into Yelp:master Nov 12, 2018
@DStape
Copy link
Contributor Author

DStape commented Nov 13, 2018

Thanks @macisamuele.

@DStape
Copy link
Contributor Author

DStape commented Nov 13, 2018

One last thing @macisamuele - is there an ETA on when this will be released? (Maybe v5.1.0 given that a new option has been added?) Thanks again.

@DStape DStape deleted the fix-basePath-used-to-build-api-url-#299 branch November 29, 2018 21:14
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.

3 participants