Effect CommunityEC
Effect Community2y ago
3 replies
mkrause

Published OpenAPI to @effect/schema Code Generator

I've published the OpenAPI to @effect/schema code generator that I've been working on: https://www.npmjs.com/package/openapi-to-effect

It takes an OpenAPI v3.1 document and converts the schemas to
@effect/schema
definitions. Previously the tool used OpenAPI v3.0, but currently it supports v3.1 only. OpenAPI v3.1 is aligned with JSON Schema, so it's basically a JSON Schema to effect generator, just with support for inter-document references.

Some of the features:

- Can output either one module per schema or bundled together.
- When bundled, automatically sorts the schemas according to a topological sort, with S.suspend() injected when a cyclic reference is detected. In this case, type annotations of the suspended schema must be manually provided through a spec file.
- Hooks are supported to customize the code gen.
- Pretty printing of the output, intelligent injection of line/block comments based on title/description fields.
Was this page helpful?