Add APIFAIRY_APISPEC_VERSION config option#92
Add APIFAIRY_APISPEC_VERSION config option#92miguelgrinberg merged 3 commits intomiguelgrinberg:mainfrom
APIFAIRY_APISPEC_VERSION config option#92Conversation
a2b72af to
e420155
Compare
|
Hi, thanks for your contribution! The problem that I see with this change is that it isn't doing anything other than stamping the version you provide. It is misleading, because one would think that if you request a given version of OpenAPI then the definitions will be made compatible with that version, or at least an error would be generated if this cannot be done, but none of that is done, so changing the default version selected by this package is very likely going to get you in trouble. Also you have made it so that the version that you specify is completely ignored when webhooks are defined. This is also unexpected. I really prefer to leave which version to use up to this package. If you need to do an override and you know what you are doing, then you can add a process_apispec handler and modify the generated spec as you need. |
Thanks for the quick response! The main aim I'm trying to get with this PR it to allow me to generate a |
|
Wouldn't the @apifairy.process_apispec
def edit_apispec(apispec):
apispec['openapi'] = '3.1.0'
return apispec |
|
The |
|
Oh okay. I don't think I remember seeing different output between 3.0.3 and 3.1.0, but it does look like there are some changes in the 3.1 serialization format, so I now understand the problem better. Okay, I'm rethinking my answer from above. Let's add the version option, but with the following changes:
Does this sound better? |
|
Yes that sounds good 👍. I'll push up some more changes to the PR this week when I'm able to. |
804739a to
6d8d9ee
Compare
|
@miguelgrinberg I think I'm happy enough with the recent changes. I would appreciate any more feedback or suggestions you might have! |
|
@miguelgrinberg Do you have any more feedback for this PR? If not, are you happy enough to merge it and publish a new version of APIFairy? |
|
Thanks! Release as version 1.5.0. |
Added a new
APIFAIRY_APISPEC_VERSIONconfig option to allow users to specify what openapi documentation version they want to generate for their project viaapispec. Currently you have to use the@webhookdecorator just to be able to do this, which not all projects use. The default behaviour has been preserved to not cause any breaking changes, which is to use3.1.0if the@webhookdecorator is used or fall back to3.0.3ifAPIFAIRY_APISPEC_VERSIONis not provided.I also updated the existing tests to work with latest versions of
marshmallowandflask. I also added some new tests to cover the newAPIFAIRY_APISPEC_VERSIONconfig option.