smithy-lang / smithy

Smithy is a protocol-agnostic interface definition language and set of tools for generating clients, servers, and documentation for any programming language.
https://smithy.io
Apache License 2.0
1.75k stars 205 forks source link

Add json-schema builder #1173

Open stephenliang opened 2 years ago

stephenliang commented 2 years ago

I saw there is a json-schema smithy builder however smithy doesn't seem to support exporting the models to json-schema as an output and it seems like the json-schema builder is an intermediary for OpenAPI.

The use case I have is to have Smithy create a JSON Schema file which can then be imported into dynamic form builders that consumes JSON Schema. Is there a workaround to enable JSON Schema to be exported?

kstich commented 2 years ago

We use the smithy-jsonschema library as the basis for conversion to OpenAPI (smithy-openapi) and to generate CloudFormation Resource Schemas (smithy-aws-cloudformation). We don't currently offer a straight-to-JSON Schema build output, mostly because so many different outputs build on top of JSON Schema with specific use cases (for example, how do they handle Smithy's service, resource, and operation shapes?)

For your specific use case, you can create a Smithy build plugin by implementing the SmithyBuildPlugin interface and using the JsonSchemaConverter to jump-start the process.

kstich commented 1 year ago

I think any implementation of this should come after a solution to adding shapes directly to a service, akin to #1061 .