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

Documenting namespace.route path strings #683

Open
Peter-J-Freeman opened this issue Aug 14, 2019 · 1 comment
Open

Documenting namespace.route path strings #683

Peter-J-Freeman opened this issue Aug 14, 2019 · 1 comment

Comments

@Peter-J-Freeman
Copy link

Hi,

Sorry if this question has been answered several times, but I'm struggling to figure out which method I need to use to add "help" documentation to namespace.route path strings.

I also want to be able to customise the text in the text-field box shown on the rendered page, both for the documented path strings and a parser object

Here is my minimal code

from flask import Flask
from flask_restplus import Api, Resource, reqparse

application = Flask(__name__)
api = Api(app = application)

parser = reqparse.RequestParser()
parser.add_argument('content-type',
                    type=str,
                    help='my helpful text',
                    location = 'form')

name_space = api.namespace('name', description='Return a name provided by the user')
@name_space.route("<string:name>") # I WANT TO ADD HELP TEXT;  PATH AND REQUIRED
class NameClass(Resource):
    @api.doc(parser=parser) # WORKS BUT I WANT TO SPECIFY THE TEXT IN THE BOX
    def get(self, name):
        args = parser.parse_args()
        return {
            "My name is" : name,
            "args": args # WORKS
        }


# Allows app to be run in debug mode
if __name__ == '__main__':
    application.debug = True
    application.run(host="127.0.0.1", port=5000)

I have annotated the sections I need help with

Many thanks

@Peter-J-Freeman
Copy link
Author

Hi,

So I figured out how to document the path variables using

@name_space.param("name", "Some description")

Is there any way I can add custom example text in the text-box, or just stop it being displayed?

Thanks

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

1 participant