mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 01:12:56 +03:00
Add a binary for generating the OpenAPI schema for the metadata type. (#453)
<!-- Thank you for submitting this PR! :) --> ## Description I needed this, so I made it. It's nothing too complex: we just pretty-print the `schemars` schema for the root `Metadata` type. <!-- Questions to consider answering: 1. What user-facing changes are being made? 2. What are issues related to this PR? (Consider adding `(close #<issue-no>)` to the PR title) 3. What is the conceptual design behind this PR? 4. How can this PR be tested/verified? 5. Does the PR have limitations? 6. Does the PR introduce breaking changes? --> ## Changelog - Add a changelog entry (in the "Changelog entry" section below) if the changes in this PR have any user-facing impact. See [changelog guide](https://github.com/hasura/graphql-engine-mono/wiki/Changelog-Guide). - If no changelog is required ignore/remove this section and add a `no-changelog-required` label to the PR. ### Product _(Select all products this will be available in)_ - [ ] community-edition - [ ] cloud <!-- product : end : DO NOT REMOVE --> ### Type <!-- See changelog structure: https://github.com/hasura/graphql-engine-mono/wiki/Changelog-Guide#structure-of-our-changelog --> _(Select only one. In case of multiple, choose the most appropriate)_ - [ ] highlight - [ ] enhancement - [ ] bugfix - [ ] behaviour-change - [ ] performance-enhancement - [ ] security-fix <!-- type : end : DO NOT REMOVE --> ### Changelog entry <!-- - Add a user understandable changelog entry - Include all details needed to understand the change. Try including links to docs or issues if relevant - For Highlights start with a H4 heading (#### <entry title>) - Get the changelog entry reviewed by your team --> _Replace with changelog entry_ <!-- changelog-entry : end : DO NOT REMOVE --> <!-- changelog : end : DO NOT REMOVE --> V3_GIT_ORIGIN_REV_ID: a9e75bfa06c35577c17d8cbf0d021b1f56826a28
This commit is contained in:
parent
89db601cfd
commit
4dc02b0967
9
v3/Cargo.lock
generated
9
v3/Cargo.lock
generated
@ -1798,6 +1798,15 @@ dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "metadata-schema-generator"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"open-dds",
|
||||
"schemars",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mime"
|
||||
version = "0.3.17"
|
||||
|
10
v3/crates/metadata-schema-generator/Cargo.toml
Normal file
10
v3/crates/metadata-schema-generator/Cargo.toml
Normal file
@ -0,0 +1,10 @@
|
||||
[package]
|
||||
name = "metadata-schema-generator"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
|
||||
[dependencies]
|
||||
open-dds = { path = "../open-dds" }
|
||||
serde_json = "1.0.92"
|
||||
schemars = { version = "0.8.12", features = ["smol_str"] }
|
9
v3/crates/metadata-schema-generator/README.md
Normal file
9
v3/crates/metadata-schema-generator/README.md
Normal file
@ -0,0 +1,9 @@
|
||||
# Metadata Schema Generator
|
||||
|
||||
When we make changes to the metadata schema, we need to regenerate the
|
||||
goldenfile to make the tests happy. We can use the following command to get the
|
||||
schema immediately for whatever reason:
|
||||
|
||||
```bash
|
||||
$ cargo run --bin metadata-schema-generator
|
||||
```
|
8
v3/crates/metadata-schema-generator/src/main.rs
Normal file
8
v3/crates/metadata-schema-generator/src/main.rs
Normal file
@ -0,0 +1,8 @@
|
||||
use open_dds::traits::gen_root_schema_for;
|
||||
use open_dds::Metadata;
|
||||
use schemars::gen::SchemaGenerator;
|
||||
|
||||
fn main() {
|
||||
let schema = gen_root_schema_for::<Metadata>(&mut SchemaGenerator::default());
|
||||
println!("{}", serde_json::to_string_pretty(&schema).unwrap());
|
||||
}
|
Loading…
Reference in New Issue
Block a user