Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,30 @@ Edit the source yaml files and build the package:
yarn build
```

### Regenerating types

TypeScript types ([`src/generated-types.ts`](src/generated-types.ts)) are regenerated as part of `yarn build`, or standalone with:

```console
yarn generate-types
```

Rust types (the [`rust/`](rust/) crate) are generated from the bundled [`openapi.yaml`](openapi.yaml), so run `yarn build` (or at least `yarn bundle`) first if you have changed the source yaml files. The generation uses [openapi-generator](https://github.com/OpenAPITools/openapi-generator), which requires a Java runtime:

```console
yarn generate-types:rust
```

If you don't have Java installed, use the Docker variant, which runs the same generator version inside a container:

```console
yarn generate-types:rust:docker
```

The generator version is pinned in [`openapitools.json`](openapitools.json) — when bumping it, update the image tag in the `generate-types:rust:docker` script to match.

> Note that the Rust generation emits models only (`apis=false`), so spec changes that only touch endpoints or query parameters produce no changes in the crate.

### Midnight GraphQL docs

The Midnight Indexer GraphQL API documentation is generated using [SpectaQL](https://github.com/anvilco/spectaql) from the schema file [`midnight-indexer-api.graphql`](midnight-indexer-api.graphql). The SpectaQL configuration is in [`spectaql.yaml`](spectaql.yaml) and the custom theme is in [`spectaql-theme/`](spectaql-theme/).
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"build:midnight-docs": "yarn spectaql ./spectaql.yaml && cp ./midnight-indexer-api.graphql ./docs/midnight/midnight-indexer-api.graphql",
"generate-types": "yarn openapi-typescript ./openapi.yaml --output ./src/generated-types.ts",
"generate-types:rust": "rimraf ./rust/src/models && openapi-generator-cli generate -i openapi.yaml -g rust -o ./rust -c rust/openapi-generator.json -t rust/templates --global-property models,modelDocs=false,apis=false,apiDocs=false,supportingFiles && node rust/fix-cargo.js",
"generate-types:rust:docker": "rimraf ./rust/src/models && docker run --rm -v \"$PWD:/local\" openapitools/openapi-generator-cli:v7.20.0 generate -i /local/openapi.yaml -g rust -o /local/rust -c /local/rust/openapi-generator.json -t /local/rust/templates --global-property models,modelDocs=false,apis=false,apiDocs=false,supportingFiles && node rust/fix-cargo.js",
"generate-json-schema": "node lib/scripts/generate-json-schema.js > json-schema.json",
"sync-version": "ts-node ./src/scripts/sync-version.ts",
"test": "vitest",
Expand Down
Loading