dankinsoid / VaporToOpenAPI

OpenAPI specification generator for Vapor based Swift projects.
MIT License
98 stars 8 forks source link

Question: No Visual Swagger Generated.... #3

Closed nanashili closed 1 year ago

nanashili commented 1 year ago

So I'm playing around with this library that seems fantastic but the only issue is when you run the your backend there is no swagger website being generated only the swagger json. I tried the example and same issue persists.

The only part of the library that actually works is the fetching the swagger.json file

dankinsoid commented 1 year ago

@nanashili It's correct behavior, there are a few ways to integrate SwiggerUI into your server, so I leave this work outside the library. The simplest way is to use the dist folder as in the example project. You can create a separate route for the SwaggerUI index.html (I do this in my projects) or set up a default file for the public directory as in the example. When using the second method, do not forget to append / at the end of the path when opening the page. Also in the scheme settings in Xcode specify the project root folder as a working directory.

nanashili commented 1 year ago

Could you give an example on how to set the SwaggerUI index.html as a route or even make a public file the default file?

dankinsoid commented 1 year ago

@nanashili sure I use leaf in my projects so I renamed index.html to swagger.leaf, saved it to Resources/Views folder, updated paths in the file and the route is


    func boot(routes: RoutesBuilder) throws {
        routes.get("api") { req in
            req.view.render("swagger")
        }
        .excludeFromOpenAPI()
    }

But the other way is easier, did you try to run the petstore project?

nanashili commented 1 year ago

Hi @dankinsoid, yes I have tried to run the example project... Here is a recording of what happens.

https://user-images.githubusercontent.com/63672227/231104766-1af4893d-4b46-42d0-9145-b07f7b6990a9.mov

dankinsoid commented 1 year ago

Maybe try swagger/index.html

nanashili commented 1 year ago

@dankinsoid I tried that and it doesn't work either

dankinsoid commented 1 year ago

@nanashili Which swift/vapor version?

nanashili commented 1 year ago

On the example I'm using the one provided by the library and on my personal API I'm using vapor 4.75.0 and swift 5.6

dankinsoid commented 1 year ago

@nanashili To be honest I don't know what can be wrong maybe try smth like chmod -R -x Example