Skip to content

Commit

Permalink
Mostly fix json schema generation for otel config. (#607)
Browse files Browse the repository at this point in the history
* Mostly fix json schema generation for otel config.
This is such a big part of the config that it's worth having.
It's possible that the schema is a little too lenient, and would allow invalid config for custom attributes or headers, but mostly it is OK.

* CHANGELOG.md

* Fix Http exporter schema gen

* Fix failing test.
Add comment to say what a mirror enum is used for.

Co-authored-by: bryn <bryn@apollographql.com>
  • Loading branch information
BrynCooke and bryn authored Mar 10, 2022
1 parent 7268f26 commit 3e42bf6
Show file tree
Hide file tree
Showing 7 changed files with 374 additions and 30 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
use a layer vs a plugin. As the layer API is a subset of the plugin API the layer option has been removed.
## 🚀 Features
## 🐛 Fixes
- **Reporting plugin schema generation** ([PR #607](https://github.com/apollographql/router/pull/607))
Previously our reporting plugin configuration did not participate in json schema generation. This is now broadly correct
and make writing schema much easier.
To generate a schema use the following command.
```
router --schema > apollo_configuration_schema.json
```
and follow the instructions for associating it with your particular text editor/IDE.
## 🛠 Maintenance
## 📚 Documentation

Expand Down
7 changes: 5 additions & 2 deletions apollo-router/src/configuration/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ pub(crate) fn default_service_namespace() -> String {
"apollo".to_string()
}

#[derive(Debug, Clone, Deserialize, Serialize)]
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)]
#[serde(deny_unknown_fields, rename_all = "snake_case")]
pub enum Secret {
Env(String),
Expand All @@ -292,7 +292,7 @@ impl Secret {
}
}

#[derive(Debug, Clone, Default, Deserialize, Serialize)]
#[derive(Debug, Clone, Default, Deserialize, Serialize, JsonSchema)]
#[serde(deny_unknown_fields)]
pub struct TlsConfig {
domain_name: Option<String>,
Expand Down Expand Up @@ -331,6 +331,8 @@ mod tests {
use super::*;
use apollo_router_core::prelude::*;
use apollo_router_core::SchemaError;
#[cfg(unix)]
#[cfg(any(feature = "otlp-grpc"))]
use insta::assert_json_snapshot;
use reqwest::Url;
use schemars::gen::SchemaSettings;
Expand All @@ -346,6 +348,7 @@ mod tests {
}

#[cfg(unix)]
#[cfg(any(feature = "otlp-grpc"))]
#[test]
fn schema_generation() {
let settings = SchemaSettings::draft2019_09().with(|s| {
Expand Down
Loading

0 comments on commit 3e42bf6

Please sign in to comment.