Closed proepkes closed 5 years ago
Not out of the box but it's something in the back of my mind.
There is a feature in netcore 2.1 that didn't make the cut which might go to help the enablement of this in Carter but I'm not sure when it's scheduled to run.
The other option would be to make Carter routes have an input/output model that could be decorated somehow for Swagger/OpenAPI.
You might end up with something like Get<InputModel, OutputModel>("/products", async context => context.Response.AsJson(new OutputModel());
If you have any thoughts or want to help implement it lets continue the discussion here
On 25 July 2018 at 13:35, proepkes notifications@github.com wrote:
Does Swagger work with Carter out of the box?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/CarterCommunity/Carter/issues/124, or mute the thread https://github.com/notifications/unsubscribe-auth/AAGapszA16tBrCeKVsnE478R19Q_9th3ks5uKGYlgaJpZM4VgAJW .
The ASP.NET Core feature was called Dispatcher but they renamed it to Global Routing. A sample is here https://github.com/aspnet/Routing/blob/release/2.2/samples/RoutingSample.Web/UseGlobalRoutingStartup.cs
Would need to see how that helps swagger though but that's what they are designing it for. Whether we can use that is another question
Swashbuckle uses MVC's ApiExplorer https://andrewlock.net/introduction-to-the-apiexplorer-in-asp-net-core/ . I presume this is a higher level than what Carter works at?
Yeah. The API explorer has a dependency on MVC which we don’t want :(
On Sun, 2 Sep 2018 at 21:47, Damian Hickey notifications@github.com wrote:
Swashbuckle uses MVC's ApiExplorer https://andrewlock.net/introduction-to-the-apiexplorer-in-asp-net-core/ . I presume this is a higher level than what Carter works at?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/CarterCommunity/Carter/issues/124#issuecomment-417958700, or mute the thread https://github.com/notifications/unsubscribe-auth/AAGapnDY5Nw-25iUpl32tKCl2CvoA7pGks5uXEPKgaJpZM4VgAJW .
BOO!
Initial spike:
public class CarterMetaModule<TRequest, TResponse>
{
public Type Request { get; } => typeof(TRequest)
public Type Respond {get; } => typeof(TResponse)
public abstract int[] StatusCodes {get;}
}
public class ListById : CarterMetaModule<PersonIn, PersonOut>
{
public int[] StatusCodes => [200,401];
}
this.Get<ListById>("/products/{id:int}", ctx => ctx.Response.Write("hi"))
This comes from a discussion with me and @JoeStead
I mean I call it a discussion, it's all his code and ideas and he is now godfather to my children and I am a much lesser man then he is
What are peoples thoughts on the API design?
Obviously a version without a TRequest
and a version without TResponse
and a version with neither will be required too. It will mean class-splosion for big projects, but it avoids attributes
I think it's lovely and it's something I always missed with NancyFx - self-documenting routes.
If I get time tonight, I'm going to spin up a quick prototype on this, I can't see it being too much effort (famous last words). Will link the branch here later
Does Swagger work with Carter out of the box?