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

Directories in API browser #346

Closed
Talkless opened this issue Dec 20, 2022 · 8 comments
Closed

Directories in API browser #346

Talkless opened this issue Dec 20, 2022 · 8 comments

Comments

@Talkless
Copy link

Here's what we see in API browser:
image

Where views are free functions:

@jsonrpc_list.method('cache_resolved_address')
@jwt_required()
def cache_resolved_address(...):
# ...

What does these "directories" in API browser mean? Can we actually group views in these kind of groups/"directories" somehow? That would be actually useful.

Thanks.

@nycholas nycholas self-assigned this Dec 20, 2022
@nycholas
Copy link
Member

nycholas commented Jan 3, 2023

Hi @Talkless,

These "directories" are grouped by the pattern "parent.children", in other words, the separator to organize these groupings is the period character (U+002E or ASCII 46), which is applied here[1].

Thank you.

[1] - https://github.com/cenobites/flask-jsonrpc/blob/master/src/flask_jsonrpc/contrib/browse/__init__.py#L55

@nycholas
Copy link
Member

Hi @Talkless,

Let me know if you would like that customizations to be offered by configurations, I do not promise anything ;).

Thank you.

@Talkless
Copy link
Author

Sorry @nycholas, I do not follow what is parent and child here.

Currently our n00b-WIP API is declared like this:

jsonrpc_report = JSONRPC(app, '/my_api/report/', enable_web_browsable_api=True)
jsonrpc_manager = JSONRPC(app, '/my_api/manager/', enable_web_browsable_api=True)
jsonrpc_list = JSONRPC(app, '/my_api/list/', enable_web_browsable_api=True)

The result is that we get different api browsers, which is inconvenient, so I thought maybe we could organize code differently, having some sort of "directories" in a single api browser page.

@Talkless
Copy link
Author

Talkless commented Jan 16, 2023

OK I've guessed it - using @jsonrpc_client_api.method('Foo.bar') makes "Foo.bar" appear in "Foo" directory.

@nycholas
Copy link
Member

@Talkless for your question regarding having different API browsers, try to use the modular[1] one instead of the multisite[2].

Thank you.

[1] - https://github.com/cenobites/flask-jsonrpc/tree/master/examples/modular
[2] - https://github.com/cenobites/flask-jsonrpc/tree/master/examples/multiplesite

@nycholas nycholas added the bug label Jan 17, 2023
@nycholas
Copy link
Member

Hey, I saw an issue with that, I will investigate it.

@nycholas nycholas reopened this Jan 17, 2023
@nycholas
Copy link
Member

@Talkless the issue here is when the Server is defined by Blueprints, which is a modular way to create a JSON-RPC server with Flask-JSONRPC.

app = Flask('modular')
jsonrpc = JSONRPC(app, '/api', enable_web_browsable_api=True)
jsonrpc.register_blueprint(app, user, url_prefix='/user', enable_web_browsable_api=True)
jsonrpc.register_blueprint(app, article, url_prefix='/article', enable_web_browsable_api=True)

That is different than using the distinct JSON-RPC Servers (multisite), like:

app = Flask('multiplesite')
jsonrpc_v1 = JSONRPC(app, '/api/v1', enable_web_browsable_api=True)
jsonrpc_v2 = JSONRPC(app, '/api/v2', enable_web_browsable_api=True)

The behavior that was expected is that when using the modular way, the API Browser merges in one, instead of having one API Browser for each one.

@Talkless
Copy link
Author

Thanks for explanation. Both modes are useful, and actually splitting "public" and "admin"-mode APIs is a requirement for us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants