yahehe / Nancy.Swagger

Nancy plugin for generated API documentation in Swagger format.
MIT License
133 stars 60 forks source link

Failed to load spec. #144

Closed arthg closed 6 years ago

arthg commented 6 years ago

Attempting to follow along with the Getting Started wiki, using the builders method, a la the Nancy.Swagger.Demo.

See https://github.com/arthg/BillPay.Core

Expected result: render generated API documentation in Swagger format

Actual result: Swagger chrome is rendered, but "Failed to load spec."

catcherwong commented 6 years ago

@arthg Based on your demo , I find some mistakes !

  1. The namespace of HeartbeatModule should be BillPayApi.Core.Heartbeat !

    The wiki page also introduce more details about namespace that you should know .

  2. You miss Response when you use Describe in HeartbeatMetadataModule .

public HeartbeatMetadataModule()
{
    Describe["GetHeartbeat"] = description => description.AsSwagger(
    with => with.Operation(
        op => op.OperationId("GetHeartbeat")
                .Tag("Heartbeat")
                .Summary("Heartbeat")
                //Don't forget Response here!!
                .Response(r=>r.Description("desc"))
                .Description("This returns status code 200 and some blah blah blah when the service is alive and heart is beating")));
}
arthg commented 6 years ago

Those 2 suggestions got me up and running. Did not notice the namespace issue without the "eyes of Resharper" on my personal machine. Once in the office it becomes obvious. I did not realize the Response was required.

Thank you!

jnallard commented 6 years ago

Thanks, @catcherwong for the assistance.

Yeah, the namespace issue is annoying. We should find a way to make it more obvious or maybe document it in the samples too.

And hopefully if there was a problem with Response not being set, the swagger validator would have said something?