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

Expose the inputs and outputs in the openapi.json files #672

Open
MatthieuBizien opened this issue Feb 18, 2022 · 4 comments
Open

Expose the inputs and outputs in the openapi.json files #672

MatthieuBizien opened this issue Feb 18, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@MatthieuBizien
Copy link

Is your feature request related to a problem? Please describe.

Gradio documents the API in the /api route, which is really nice for understanding an API.

Having a machine-readable version of that page would be very useful for automatic verification of the coherency of the gradio, including:

  • Do the caller provide all the necessary inputs?
  • Are the inputs correctly typed and formatted?
  • What are the acceptable values of dropdowns, sliders?
  • What are the labels of the inputs and outputs?

Describe the solution you'd like

The standard place for that information would be /openapi.json , that can represent data models, including:

  • Integer and Float (incl. minimum, maximum, multipleOf)
  • Text
  • Enums <-> Dropdown
  • Files

The JSON keywords also match most of the options of the Gradio inputs, incl.

  • description for label
  • minimum, maximum

Additional context

Because Gradio use FastAPI + Pydantic + Swagger, it could be enough to define dynamic Pydantic models and use them when creating the application.

An alternative solution would be to just expose the data of the /api route as json, without using the standard.

@abidlabs abidlabs added this to the 2.9.0 milestone Feb 18, 2022
@aliabd
Copy link
Collaborator

aliabd commented Mar 9, 2022

Hey @MatthieuBizien thanks for the detailed notes here! We discussed this suggestion internally and feel it's a bit too early. I'm going to close this issue but we'll take another look at it sometime in the future.

In any case, if you're strongly in favor of this, we would be open for a PR.

@aliabd aliabd closed this as completed Mar 9, 2022
@aliabd aliabd reopened this Mar 9, 2022
@aliabd
Copy link
Collaborator

aliabd commented Mar 9, 2022

Actually, we decided to keep it open for now :)

@aliabd aliabd removed their assignment Mar 10, 2022
@abidlabs abidlabs added the enhancement New feature or request label Apr 19, 2022
@abidlabs abidlabs removed this from the 3.0 milestone Apr 19, 2022
@abidlabs
Copy link
Member

Same as #2364, closing as there is more activity on that one. Thanks for the request @MatthieuBizien

@abidlabs
Copy link
Member

abidlabs commented Apr 7, 2023

Reopening this. For the client, we already have the ability to programmatically inspect the APIs using the /info routes, but that is a custom json format. Would be good to also have a route, maybe /openapi.json (the standard fastapi route I think) that exposes in openapi format

Slack discussion: https://huggingface.slack.com/archives/C02SPHC1KD1/p1680887663305069?thread_ts=1680694519.500639&cid=C02SPHC1KD1

@abidlabs abidlabs reopened this Apr 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants