Can I generate a server endpoint from refit definitions? #1449
-
|
I am writing a new SaaS style app using Blazor Wasm for client, and Asp Core for server. Is it possible to use Refit to generate the server endpoints also? especially to do things like generate OpenApi docs. If not, could you please give some advice on the best way to generate both client and server (+OpenApi docs) while still utilizing Refit, that would be great. Sorry if my request is a bit hard to follow, I am pretty new to Blazor/Asp, but am a good C# dev so please don't hesitate to offer a suggestion :) |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
|
I found the following related:
seems the best route would be to create the server api + OpenApi Spec and then work on building the client from there, maybe using the above links as resources. |
Beta Was this translation helpful? Give feedback.
-
|
one of these seems to be possible. Has anyone had luck with either? Maybe adding some docs around what works would be nice. |
Beta Was this translation helpful? Give feedback.
-
|
I don't know of anything like that but it's definitely a cool idea! |
Beta Was this translation helpful? Give feedback.
-
|
Refit is a client-only library - it generates HTTP client implementations from interfaces and has no server-side / endpoint generation. There is no built-in way to emit ASP.NET Core endpoints or OpenAPI docs from a Refit interface. For a Blazor WASM + ASP.NET Core SaaS, the practical flow is server-first:
So the OpenAPI document is the source of truth in the middle; the server defines it and the client is generated from it. Going the other direction (Refit interface -> server + OpenAPI) is not something Refit supports. |
Beta Was this translation helpful? Give feedback.
Refit is a client-only library - it generates HTTP client implementations from interfaces and has no server-side / endpoint generation. There is no built-in way to emit ASP.NET Core endpoints or OpenAPI docs from a Refit interface.
For a Blazor WASM + ASP.NET Core SaaS, the practical flow is server-first:
So the OpenAPI document is the source of truth in the middle;…