volfpeter / fasthx

FastAPI server-side rendering with built-in HTMX support.
https://volfpeter.github.io/fasthx/
MIT License
458 stars 9 forks source link

Swagger compliant `HX-Request` headers. #5

Closed hasansezertasan closed 10 months ago

hasansezertasan commented 10 months ago

Is there a way to make these decorators swagger-compliant?

Edit: The hx-request header parameter doesn't show up on the SwaggerUI.

volfpeter commented 10 months ago

It can not be done with decorators, because the decorator is applied to / enhances the decorated function, and not the FastAPI or APIRouter get, post, etc. methods. What could be done is adding a small utility function that adds the info to the mentioned methods - this may be in the scope of this lib. Another option would be subclassing e.g. APIRouter, but that's definitely out of scope here.

hasansezertasan commented 10 months ago

It can not be done with decorators, because the decorator is applied to / enhances the decorated function, and not the FastAPI or APIRouter get, post, etc. methods.

Can't we register annotations to a function wrapped by a decorators?

What could be done is adding a small utility function that adds the info to the mentioned methods - this may be in the scope of this lib.

Are you talking about modifying the OpenAPI Schema?

Another option would be subclassing e.g. APIRouter, but that's definitely out of scope here.

I couldn't agree more!

volfpeter commented 10 months ago

I think I see what you meant now. This could be fixed by adding a Header dependency to get_hx_request(). I'll get it done soon.

hasansezertasan commented 10 months ago

I think I see what you meant now. This could be fixed by adding a Header dependency to get_hx_request(). I'll get it done soon.

Fantastic! I'm looking forward to seeing it flying... 🥏 Leaving this issue open, don't forget to address this issue when you open a PR 😇.

volfpeter commented 10 months ago

Released :)

hasansezertasan commented 10 months ago

Damn!