xerions / phoenix_swagger

Swagger integration to Phoenix framework
Mozilla Public License 2.0
691 stars 181 forks source link

possibility to remove host in configuration #255

Open spinettaro opened 4 years ago

spinettaro commented 4 years ago

Hi all,

is there a way to remove the host from final swagger file? I read other issues and I know that is possible to set it to empty string or null, but it is not good for OPEN API specification and consequentially validation - https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md .

I have to achieve this If host is not specified, it is assumed to be the same host where the API documentation is being served. . and the only way to achieve that and be valid for API specification I have to remove completely the host key.

Any suggestions?

AndriiKlymchuk commented 3 years ago

@spinettaro, I also faced this problem. The solution is to remove ednpoint from phoenix_swagger config.

config :myapp, :phoenix_swagger,
  swagger_files: %{
    "priv/static/swagger.json" => [
      router: MyApp.Router,
      endpoint: MyApp.Endpoint # <--- remove this line
    ]
  },
  json_library: Jason

If endpoint is not set and host is not specified in swagger_info/0 callback, then host key is omitted in swagger.json