starlette-admin icon indicating copy to clipboard operation
starlette-admin copied to clipboard

Enhancement: Support Swagger

Open code4rain opened this issue 3 years ago • 8 comments

Is your feature request related to a problem? Please describe. FastAPI supports OpenAPI as builtin. Is it possible to support OpenAPI to describe detail spec for another client which want to create, read, update, delete?

Describe the solution you'd like support API endpoint with OpenAPI description such as FastAPI does.

Describe alternatives you've considered

Additional context

code4rain avatar Dec 05 '22 13:12 code4rain

Hello @code4rain, I'm not sure if I understood your request correctly, Do you mean some kind of ApiView to support CRUD on models via REST API?

jowilf avatar Dec 06 '22 19:12 jowilf

Hello @jowilf

Please refer below. https://fastapi.tiangolo.com/features/#automatic-docs

Is it possible to show the rest api style(json style return) by starlette-admin?

Currrently starlette-admin generate rest api which return HTML(jinja2 based) instead of simple json style data.

  • Only I found the json style return by list api with skip and limit. I can not find create, edit, delete for it.

Thanks for your reply 😊

code4rain avatar Dec 07 '22 12:12 code4rain

Hello @code4rain,

Only the listing page follow OpenApi specification to serve datatables through RestAPI, the others endpoint use POST (multipart/form-data) request and they can't follow OpenAPI Specification due to some limitations with the way dynamic list and embedded document are handle with html and Javascript.

Take a look at this. You can see how the browser make the POST request with dynamic list (eg. array.1 array.2 array.3)

jowilf avatar Dec 10 '22 11:12 jowilf

@jowilf Thank for explain. I will check the code as you mentioned.

code4rain avatar Dec 13 '22 07:12 code4rain

@code4rain check my edited answer. I'm not sure it was clear

jowilf avatar Dec 13 '22 07:12 jowilf

@jowilf Actually, I'm using FastAPI as backend for my service and communicated with FE engineer by OpenAPI (Swagger). FE engineer does not know about internal implementation of backend. And currently, I used starlette-admin for internal admin page and make new router to communicated with FE engineer to describe the models which backend handle.

I made this issue to prevent to make new router code if possible. :)

code4rain avatar Dec 13 '22 08:12 code4rain

Sounds like a good idea, I'll reopen the issue and take a look at it when I have some free time to spend on it.

jowilf avatar Dec 13 '22 17:12 jowilf

Is there any improvement on this one? FastAPI depends on Pydantic to generate the OpenAPI Schema. Supporting this feature would probably make Pydantic a requirement.

hasansezertasan avatar Nov 08 '23 09:11 hasansezertasan