Any resources for json-schema or swagger specs?


#1

Curious if anyone is working with json-schema or swagger and authoring packages to help build tools that produce or consume these languages?

There is:

https://package.elm-lang.org/packages/1602/json-schema/latest/

And for 0.18 there was:


https://github.com/the-sett/elm-swagger (my effort, never completed or published)

I suspect the answer is “no”, but thought I’d check if anyone has something in the pipeline before I pick this up again. Right now, I’d like something that can decode a Swagger 3.0 (OpenAPI) document with the aim of building a nice UI that helps you to explore and comprehend the API and data model that it describes.


#2

For OpenApi there is an Elm generator here https://openapi-generator.tech/docs/generators.html. I haven’t used it but worth trying.


#3

Oh, interesting! We use Springfox at work to autogenerate swagger specs for our API, though we’ve only used it for documentation so far.

When I generate the Elm files though all fields become Maybe even though they’re not marked as optional in the specs :thinking:

Maybe the way to treat these generated types is as a “primer” on top of JSON, but not actually the types you use in your app?

Edit: Oh, I see, they have to be specifically marked as “required”, otherwise they are treated as optional. This is very cool!


#4

I pinged the author - this is the json-schema package to use:

https://package.elm-lang.org/packages/json-tools/json-schema/latest/

Its a more up to date fork of:

https://package.elm-lang.org/packages/1602/json-schema/latest/

presumably to publish under the json-tools name.

Seems like this is good replacement for NoRedInk/json-elm-schema and provides decoding and encoding of json-schema, as well as a builder DSL for constructing them. So that is a nice starting point for OpenAPI 3.0.


closed #5

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.