question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How does flasgger handle multiple URLs with flask-restful?

See original GitHub issue

I’m using flask-restful and have a resource with two URLs, like this:

    api.add_resource(Job, '/job/<int:job_id>', '/job')

where job_id is used only by the GET method.

In the resources code I have:

class Job(Resources):
    def get(self, job_id):
        """
        Retrieve a job from its ID
        ---
        tags:
          - Jobs
        parameters:
        - name: job_id
          in: path
          description: ID of the job
          required: true
        responses:
          200:
            description: Job found
          404:
            description: Job not found
        """

the expected result is a swagger spec with only one URL path for the GET operation, but flasgger generates a swwager spec with two URL paths for the GET one for /job/{job_id} and another one for /job.

Is it possible to separate specifications by path or method in this case?

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
pahrohfitcommented, Jul 24, 2019

Specify endpoint on each line, defining each as a separate target (as @xiaomaflying said):

api.add_resource(
    resources.auth.Register,
    '/api/v1/auth/register',
    methods=['POST'],
    endpoint="submit_registration"
)
api.add_resource(
    resources.auth.Register,
    '/api/v1/auth/register/<string:token>',
    methods=['GET'],
    endpoint="validate_registration"
)
1reaction
xiaomaflyingcommented, Sep 26, 2018

I also have this problem. image

Read more comments on GitHub >

github_iconTop Results From Across the Web

How does flasgger handle multiple URLs with flask-restful?
I'm using flask-restful and have a resource with two URLs, like this: api.add_resource(Job, '/job/ ', '/job') where job_id is used only by ...
Read more >
Two urls with difference of one optional parameter to map to ...
According the the docs and source code for flask-restful, you can pass multiple urls to match to addResource. like:
Read more >
How does flasgger handle multiple URLs with flask-restful?
I'm using flask-restful and have a resource with two URLs, like this: api.add_resource(Job, '/job/<int:job_id>', '/job'). where job_id is used only by the ...
Read more >
Working with APIs using Flask, Flask-RESTPlus and Swagger UI
The article discusses about how to use Flask and Flask-RESTPlus to create APIs and then use them to send and retrieve information.
Read more >
README.md · Flasgger/flasgger - Gitee.com
Easy OpenAPI specs and Swagger UI for your Flask API. ... YAML docs and MethodViews; Handling multiple http methods and routes for a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found