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

Parameters not see url /api/browse in decorators #61

Closed
RemiZOffAlex opened this issue Jul 1, 2018 · 4 comments
Closed

Parameters not see url /api/browse in decorators #61

RemiZOffAlex opened this issue Jul 1, 2018 · 4 comments

Comments

@RemiZOffAlex
Copy link

Parameters not see in decorators between

Work in url /api/browse

@jsonrpc.method('tag.add')
def tag_add(name):

Not work in url /api/browse

@jsonrpc.method('tag.add')
@exampleDecorator
def tag_add(name):
@nycholas
Copy link
Member

nycholas commented Jul 2, 2018

Hi,

Please look a example with decorator, https://github.com/cenobites/flask-jsonrpc/blob/master/examples/decorator/decorator.py.

Thank you.

@nycholas
Copy link
Member

nycholas commented Jul 2, 2018

Hi,

I understand the problem.

Thank you.

@RemiZOffAlex
Copy link
Author

Example code

#!/usr/bin/env python3

from __future__ import unicode_literals

from flask import Flask
from flask_jsonrpc import JSONRPC
from functools import wraps

app = Flask(__name__)
jsonrpc = JSONRPC(app, '/api', enable_web_browsable_api=True)

def decorator(func):
    @wraps(func)
    def decorated_function(*args, **kwargs):
        return func(*args, **kwargs)
    return decorated_function

@jsonrpc.method('tag.add')
def tag_add(name):
    return "OK!"

@jsonrpc.method('tag.add_decorator')
@decorator
def tag_add_decorator(name):
    return "OK!"

app.run()

This browse api and show modal form for input value for method tag.add

screen-1

This not showing form for method tag.add_decorator

screen-2

Decorator do blocked auto definition a parameters

@RemiZOffAlex
Copy link
Author

Is not problem! In JSON-RPC decorator write param and type param

@jsonrpc.method('tag.add(name=str)')

@jsonrpc.method('tag.add_decorator(name=str)')

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

2 participants