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

is there a way to load up a json dict into this package instead of from a file? #43

Open
akouminov opened this issue Feb 4, 2021 · 2 comments

Comments

@akouminov
Copy link

I dynamically generate my doc with apisec https://github.com/marshmallow-code/apispec

can I pass its output to this package or do I need to fork and customize?

Thanks!

@lausek
Copy link

lausek commented Mar 3, 2021

I had the same problem, but it seems like this package is not handling the retrieval of your swagger specification. You can try passing the json specification like this get_swaggerui_blueprint(..., config={"spec": "<json spec>"}). It should work if the swagger-ui js version is up to date.

@SamuelJansen
Copy link

I had this problem and I end up doing this:

def addSwagger(apiInstance, appInstance):
    ###- The ugliest thing I ever seen, but thats the way flask_swagger_ui works...
    documentationUrl = f'{apiInstance.baseUrl}{DOCUMENTATION_ENDPOINT}'
    swaggerUi = get_swaggerui_blueprint(
        documentationUrl,
        OpenApiDocumentationFile.getDocumentationFileName(apiInstance)
    )
    @appInstance.route(f'{documentationUrl}/{OpenApiDocumentationFile.getDocumentationFileName(apiInstance)}', methods=['GET'])
    def getSwagger() :
        return apiInstance.documentation
    appInstance.register_blueprint(swaggerUi, url_prefix=documentationUrl)

It's ugly, but honestly I see no solution other than this.

Im using a combination of Flask and flask_restful.
But I see no reason for this not to works in Flask all alone

Any problem, just reply here and I can try write a cleanner example (I just copy pasted from my project)

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

No branches or pull requests

3 participants