1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-08-09 04:22:45 +03:00

Drop the config schema generation subcommand & include it in the docs

This commit is contained in:
Quentin Gliech
2022-10-17 10:21:05 +02:00
parent f5e3aa0404
commit eeae943208
6 changed files with 1159 additions and 18 deletions

1
Cargo.lock generated
View File

@@ -2368,7 +2368,6 @@ dependencies = [
"opentelemetry-semantic-conventions", "opentelemetry-semantic-conventions",
"opentelemetry-zipkin", "opentelemetry-zipkin",
"prometheus", "prometheus",
"schemars",
"serde_json", "serde_json",
"serde_yaml", "serde_yaml",
"tokio", "tokio",

View File

@@ -11,7 +11,6 @@ futures-util = "0.3.24"
anyhow = "1.0.65" anyhow = "1.0.65"
clap = { version = "4.0.2", features = ["derive"] } clap = { version = "4.0.2", features = ["derive"] }
dotenv = "0.15.0" dotenv = "0.15.0"
schemars = { version = "0.8.10", features = ["url", "chrono"] }
tower = { version = "0.4.13", features = ["full"] } tower = { version = "0.4.13", features = ["full"] }
hyper = { version = "0.14.20", features = ["full"] } hyper = { version = "0.14.20", features = ["full"] }
serde_yaml = "0.9.13" serde_yaml = "0.9.13"

View File

@@ -14,7 +14,6 @@
use clap::Parser; use clap::Parser;
use mas_config::{ConfigurationSection, RootConfig}; use mas_config::{ConfigurationSection, RootConfig};
use schemars::gen::SchemaSettings;
use tracing::info; use tracing::info;
#[derive(Parser, Debug)] #[derive(Parser, Debug)]
@@ -28,9 +27,6 @@ enum Subcommand {
/// Dump the current config as YAML /// Dump the current config as YAML
Dump, Dump,
/// Print the JSON Schema that validates configuration files
Schema,
/// Check a config file /// Check a config file
Check, Check,
@@ -49,18 +45,6 @@ impl Options {
Ok(()) Ok(())
} }
SC::Schema => {
let settings = SchemaSettings::draft07().with(|s| {
s.option_nullable = false;
s.option_add_null_type = false;
});
let gen = settings.into_generator();
let schema = gen.into_root_schema_for::<RootConfig>();
serde_yaml::to_writer(std::io::stdout(), &schema)?;
Ok(())
}
SC::Check => { SC::Check => {
let _config: RootConfig = root.load_config()?; let _config: RootConfig = root.load_config()?;
info!(path = ?root.config, "Configuration file looks good"); info!(path = ?root.config, "Configuration file looks good");

View File

@@ -33,3 +33,6 @@ mas-jose = { path = "../jose" }
mas-keystore = { path = "../keystore" } mas-keystore = { path = "../keystore" }
mas-iana = { path = "../iana" } mas-iana = { path = "../iana" }
mas-email = { path = "../email" } mas-email = { path = "../email" }
[[bin]]
name = "schema"

View File

@@ -0,0 +1,26 @@
// Copyright 2022 The Matrix.org Foundation C.I.C.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
use schemars::gen::SchemaSettings;
fn main() {
let settings = SchemaSettings::draft07().with(|s| {
s.option_nullable = false;
s.option_add_null_type = false;
});
let gen = settings.into_generator();
let schema = gen.into_root_schema_for::<mas_config::RootConfig>();
serde_json::to_writer_pretty(std::io::stdout(), &schema).expect("Failed to serialize schema");
}

1130
docs/config.schema.json Normal file

File diff suppressed because it is too large Load Diff