Skip to content
This repository has been archived by the owner on Sep 14, 2022. It is now read-only.

Way to create swagger.json automatically #222

Open
akkihan opened this issue Apr 15, 2020 · 9 comments
Open

Way to create swagger.json automatically #222

akkihan opened this issue Apr 15, 2020 · 9 comments

Comments

@akkihan
Copy link

akkihan commented Apr 15, 2020

Hello,
I am interested in a way to create a swagger.json automatically during the application start or build phase.
Currently, I manually do a call to GET /swagger.json endpoint which returns the generated JSON file.
Is there any way I can automate this procedure?

Thanks

@robertofabrizi
Copy link

How is this project even working for you? Arent you on play 2.7 or newer? Thanks

@akkihan
Copy link
Author

akkihan commented May 26, 2020

Yes, I am on play 2.7. Every time to create swagger documentation I call the endpoint. What I would like to achieve it to be created automatically, e.g. when I build or run the app.
Thanks

@robertofabrizi
Copy link

I'm one step behind you, when I do as it says and add this:

libraryDependencies ++= Seq(
  "io.swagger" %% "swagger-play2" % "2.0.1-SNAPSHOT"
)

it looks for a jar on mavencentral that isn't here:

https://mvnrepository.com/artifact/io.swagger/swagger-play2 - 2.0.1-SNAPSHOT ain't there
How did you solve this?

@akkihan
Copy link
Author

akkihan commented May 26, 2020

This is the one for me:
"io.swagger" %% "swagger-play2" % "1.6.1"
try this one

@robertofabrizi
Copy link

That is labeled to support up to scala 2.12, but I'm on 2.13...

@akkihan
Copy link
Author

akkihan commented May 26, 2020

I think I had that issue as well when I tried to switch the scala version to 2.13. Eventually I used scala 2.12.19 and following swagger dependency:
"io.swagger" %% "swagger-play2" % "1.7.1",

@robertofabrizi
Copy link

Ah ok you downgraded the scala version. I'm a bit scared to do that just for this module to be honest.

@gaeljw
Copy link

gaeljw commented Jul 11, 2020

I want to do it at build time, I believe this would have to be some kind of SBT or Maven plugin.

If you want to do it at startup, without calling the endpoint swagger.json, you could call directly the underlying Swagger controller ApiHelpController, there are several methods that could use depending on your need.

@dwickern
Copy link
Contributor

I published a plugin for this: https://github.com/dwickern/sbt-swagger-play

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants