Fork me on GitHub
#malli
<
2022-11-28
>
mike_ananev19:11:13

Hi, there. I’m little bit confused how to transform schema to real Swagger2 structure, from example https://github.com/metosin/malli#swagger2 ? I want to write message specs using Malli and generate some artefacts for other teams which use Golang or Java. I’m trying to figure out how to do this? I’ve implemented Malli Spec -> JSON Schema, but wanna use Swagger or Protobuf. The example above is incomplete and I don’t know how to generate real swagger file.

valtteri19:11:55

If you’re describing just data schemas, your swagger documentation would probably be something like

{
  "swagger": "2.0"
  "info": {"title": "My Title", "description": "something"},
  "definitions" {
    "MyObj1": <your malli->swagger-output-here>,
    "MyObj2": <your malli->swagger-output-here>,
  }
}

👍 1
Ben Sless19:11:11

For swagger you also need data like route and method which isn't part of the schema. Protobuf support doesn't exist yet afaik

valtteri19:11:15

AFAIK swagger had slight (annoying) differences compared to JSON schema :thinking_face:

valtteri19:11:00

But anyways, as Ben said, Swagger doesn’t bring much (any) value if you’re just describing data. JSON schema should do the trick.

valtteri19:11:41

There are JSON schema libs for Java and Go

mike_ananev20:11:16

Ok, thank you. Got it! It would be good to transform Malli specs to Protobuf 3 schemas cause many teams use gRPC.

Ben Sless20:11:33

Tell them distributed objects are bad or wait until I get to PR it to malli? 🙃

👍 1