Swagger: setting tags

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Swagger: setting tags

Corentin Dupont
Hello,
I'm trying to set tags on my Swagger endpoints.

swaggerDoc :: S.Swagger
swaggerDoc = toSwagger (Proxy :: Proxy AppAPI)
    & S.info . S.title       .~ "App API"
    & S.info . S.version     .~ "v2.0.0"
    & S.info . S.description ?~ "This is the API"

I would like to apply a tag on all the endpoints, based on the URL.
For example, all endpoints starting with "/api/v1/foo" should be tagged "Foo".
How to achieve that?

Thanks a lot
Corentin

--
Reply | Threaded
Open this post in threaded view
|

Re: Swagger: setting tags

Corentin Dupont
Hey there!
This mailing list is very silent :)
I found an answer after some research:

swaggerDoc :: S.Swagger
swaggerDoc = toSwagger (Proxy :: Proxy AppAPI)
  & S.info . S.title       .~ "App API"
  & S.info . S.version     .~ "v2.0.0"
  & S.info . S.description ?~ "This is the API"
  & S.basePath ?~ "/api/v1"
  & S.applyTagsFor fooOps ["Foo"]
  & S.applyTagsFor barOps ["Bar"]
  where
    fooOps, barOps :: Traversal' S.Swagger S.Operation
    fooOps = subOperations (Proxy :: Proxy FooAPI) (Proxy :: Proxy AppAPI)
    barOps = subOperations (Proxy :: Proxy BarAPI) (Proxy :: Proxy AppAPI)

Cheers

On Tue, Nov 20, 2018 at 12:53 PM Corentin Dupont <[hidden email]> wrote:
Hello,
I'm trying to set tags on my Swagger endpoints.

swaggerDoc :: S.Swagger
swaggerDoc = toSwagger (Proxy :: Proxy AppAPI)
    & S.info . S.title       .~ "App API"
    & S.info . S.version     .~ "v2.0.0"
    & S.info . S.description ?~ "This is the API"

I would like to apply a tag on all the endpoints, based on the URL.
For example, all endpoints starting with "/api/v1/foo" should be tagged "Foo".
How to achieve that?

Thanks a lot
Corentin

--