mig-swagger-ui: Swagger servers for mig library

[ bsd3, library, web ] [ Propose Tags ] [ Report a vulnerability ]

Appends swagger servers for mig servers. Example of the usage. This code adds swagger server which is serverd on path "swagger-ui" to our server

withSwagger def server

[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.1.0.1
Dependencies aeson, aeson-pretty, base (>=4.7 && <5), blaze-html, blaze-markup, bytestring, data-default, file-embed-lzma, http-api-data, lens, mig (>=0.2.0.1), openapi3, text [details]
License BSD-3-Clause
Copyright 2023 Anton Kholomiov
Author Anton Kholomiov
Maintainer anton.kholomiov@gmail.com
Category Web
Home page https://github.com/anton-k/mig#readme
Bug tracker https://github.com/anton-k/mig/issues
Source repo head: git clone https://github.com/anton-k/mig
Uploaded by AntonKholomiov at 2023-11-05T07:01:39Z
Distributions NixOS:0.1.0.1
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 93 total (4 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2023-11-05 [all 1 reports]

Readme for mig-swagger-ui-0.1.0.1

[back to package description]

mig-swagger-ui

The package defines utils to add swagger UI for mig library. To add swagger just use function withSwagger:

main = runServer port (withSwagger def server)

With SwaggerConfig we can update defaults. To set information on app we can use mapSchema field of the swagger config.

There is type DefaultInfo to set common fields:

main = runServer port (withSwagger swaggerConfig server)
  where
    swaggerConfig =
      def
        { swaggerFile = "swagger.json"
        , staticDir = "swagger-ui"
        , mapSchema = pure . addDefaultInfo info
        }

    info =
      DefaultInfo
        { title = "Hello world app"
        , description = "Demo application"
        , version = "1.0"
        }

Also see package openapi3 on how to update OpenApi schema.

Aknowledgments

Thanks to Oleg Grenrus for providing servant-swagger-ui library on which this package is based on. Thanks to David Johnson, Nickolay Kudasov, Maxim Koltsov authors of openapi3 and servant-openapi3 libraries. The mapping from Mig's Api to OpenApi is based on those packages.