Skip to content

Commit

Permalink
fix(doc): Avoid unnecessary line-wrapping in schema docs (#698)
Browse files Browse the repository at this point in the history
schemars does some funny text processing that destroys our beautiful hand-crafted markdown. Fork that dependency, add option to disable the behavior and use it here.

GREsau/schemars#45
  • Loading branch information
untitaker authored Jul 31, 2020
1 parent 375a83c commit f5a42c3
Show file tree
Hide file tree
Showing 6 changed files with 281 additions and 272 deletions.
18 changes: 11 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jsonschema = ["relay-general/jsonschema"]
[profile.release]
debug = true

# Direct dependencies of the main application in `src/`
[dependencies]
chrono = "0.4.11"
clap = { version = "2.33.0", default-features = false, features = ["wrap_help"] }
Expand All @@ -47,7 +48,6 @@ relay-config = { path = "relay-config" }
relay-server = { path = "relay-server" }
relay-general = { path = "relay-general" }
sentry = { version = "0.18.0", features = ["with_debug_meta"] }
schemars = { version = "0.7.1", features = ["uuid", "chrono"] }
serde = "1.0.114"
serde_json = "1.0.55"
hostname = "0.3.1"
Expand Down
2 changes: 1 addition & 1 deletion relay-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ lru = "0.4.0"
parking_lot = "0.10.0"
regex = "1.3.9"
sentry-types = "0.14.1"
schemars = { version = "0.7.1", features = ["uuid", "chrono"], optional = true }
schemars = { version = "0.8.0-alpha-4", git = "https://github.com/untitaker/schemars", branch = "preserve-formatting", features = ["uuid", "chrono"], optional = true }
serde = { version = "1.0.114", features = ["derive"] }

[features]
Expand Down
2 changes: 1 addition & 1 deletion relay-general/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ uaparser = { version = "0.3.3", optional = true }
url = "2.1.1"
uuid = { version = "0.8.1", features = ["v4", "serde"] }
relay-common = { path = "../relay-common" }
schemars = { version = "0.7.1", features = ["uuid", "chrono"], optional = true }
schemars = { version = "0.8.0-alpha-4", git = "https://github.com/untitaker/schemars", branch = "preserve-formatting", features = ["uuid", "chrono"], optional = true }

[dev-dependencies]
difference = "2.0.0"
Expand Down
7 changes: 6 additions & 1 deletion relay-general/derive/src/jsonschema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ pub fn derive_jsonschema(mut s: synstructure::Structure<'_>) -> TokenStream {
let field_attrs = parse_field_attributes(index, &bi.ast(), &mut is_tuple_struct);
let name = field_attrs.field_name;

fields = quote!(#fields #[schemars(rename = #name)]);
fields = quote! {
#fields
#[schemars_preserve_doc_formatting]
#[schemars(rename = #name)]
};

if !field_attrs.required.unwrap_or(false) {
fields = quote!(#fields #[schemars(default = "__schemars_null")]);
Expand Down Expand Up @@ -80,6 +84,7 @@ pub fn derive_jsonschema(mut s: synstructure::Structure<'_>) -> TokenStream {
#[derive(schemars::JsonSchema)]
#[cfg_attr(feature = "jsonschema", schemars(untagged))]
#[cfg_attr(feature = "jsonschema", schemars(deny_unknown_fields))]
#[schemars_preserve_doc_formatting]
#attrs
enum Helper {
#arms
Expand Down
Loading

0 comments on commit f5a42c3

Please sign in to comment.