Skip to content

Generating Specs

Before running drift-guard you need schema files on disk. Below are the most common tools for each language and schema type.

OpenAPI

Node.js

ToolFrameworkCommandOutput
@nestjs/swaggerNestJSnest build + export via SwaggerModuleopenapi.json
swagger-jsdocExpress / Fastifynpx swagger-jsdoc -d swaggerDef.js routes/*.js -o openapi.jsonopenapi.json
fastify-swaggerFastifyapp.ready(() => writeFileSync('openapi.json', JSON.stringify(app.swagger())))openapi.json
tsoaExpress / Koanpx tsoa specbuild/swagger.json

Go

ToolFrameworkCommandOutput
swagGin / Echo / Fiberswag init -g main.go -o docsdocs/swagger.yaml
oapi-codegennet/http / Chischema-first — write .yaml, generate codehand-authored
humanet/http / Chischema auto-generated at startup; dump via /openapi.jsonserved at runtime

GraphQL

Node.js

ToolFrameworkCommandOutput
graphql-inspectorApollo / Yoganpx graphql-inspector introspect http://localhost:4000 --write schema.graphqlschema.graphql
get-graphql-schemaAnynpx get-graphql-schema http://localhost:4000 > schema.graphqlschema.graphql
@graphql-codegenApollo / Yoganpx graphql-codegen --config codegen.tsconfigurable
Apollo ServerApollorover graph introspect http://localhost:4000 > schema.graphqlschema.graphql

Go

ToolFrameworkCommandOutput
gqlgengqlgenschema-first — graph/schema.graphqls is your sourcehand-authored
graph-gophers/graphql-gonet/httpschema defined as Go string literal; export to filehand-authored
IntrospectionAny servercurl -X POST http://localhost:8080/graphql -d '{"query":"{__schema{...}}"}' | jq > schema.jsonschema.json

gRPC / Protobuf

Node.js

ToolFrameworkCommandOutput
@grpc/proto-loadergrpc-js.proto files are the source of truth — check them in directlyhand-authored
ts-protogrpc-jsprotoc --plugin=protoc-gen-ts_proto --ts_proto_out=. service.protogenerated TS; .proto is source
bufAnybuf build --output image.bin (or use .proto files directly).proto / BSR

Go

ToolFrameworkCommandOutput
protocgoogle.golang.org/grpc.proto files are the source of truth — check them in directlyhand-authored
bufAnybuf generategenerated Go; .proto is source
grpc-gatewaygrpc-gatewayannotate .proto, generate OpenAPI via protoc-gen-openapiv2apidocs.swagger.json

Quick reference

Schema typeMinimum drift-guard input
OpenAPIAny .yaml or .json file valid against OpenAPI 3.x
GraphQLSDL file (.graphql / .gql) or introspection JSON
gRPCA .proto file using syntax = "proto3"

Released under the MIT License.