Skip to content

Commit a2f7439

Browse files
committed
[config] add $schema to config.json
1 parent 2559e0d commit a2f7439

7 files changed

Lines changed: 9 additions & 36 deletions

docs/schemas/event-file-format-detected-v1.schema.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@
44
"$schema": "http://json-schema.org/draft-07/schema#",
55
"description": "Event fired when a log format is detected for a file.",
66
"properties": {
7-
"$schema": {
8-
"title": "/$schema",
9-
"type": "string",
10-
"const": "https://lnav.org/event-file-format-detected-v1.schema.json"
11-
},
127
"filename": {
138
"title": "/filename",
149
"description": "The path of the file for which a matching format was found",

docs/schemas/event-file-open-v1.schema.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@
44
"$schema": "http://json-schema.org/draft-07/schema#",
55
"description": "Event fired when a file is opened.",
66
"properties": {
7-
"$schema": {
8-
"title": "/$schema",
9-
"type": "string",
10-
"const": "https://lnav.org/event-file-open-v1.schema.json"
11-
},
127
"filename": {
138
"title": "/filename",
149
"description": "The path of the file that was opened",

docs/schemas/event-log-msg-detected-v1.schema.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@
44
"$schema": "http://json-schema.org/draft-07/schema#",
55
"description": "Event fired when a log message is detected by a watch expression.",
66
"properties": {
7-
"$schema": {
8-
"title": "/$schema",
9-
"type": "string",
10-
"const": "https://lnav.org/event-log-msg-detected-v1.schema.json"
11-
},
127
"watch-name": {
138
"title": "/watch-name",
149
"description": "The name of the watch expression that matched this log message",

docs/schemas/event-session-loaded-v1.schema.json

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,5 @@
33
"title": "https://lnav.org/event-session-loaded-v1.schema.json",
44
"$schema": "http://json-schema.org/draft-07/schema#",
55
"description": "Event fired when a session is loaded.",
6-
"properties": {
7-
"$schema": {
8-
"title": "/$schema",
9-
"type": "string",
10-
"examples": [
11-
"https://lnav.org/event-session-loaded-v1.schema.json"
12-
]
13-
}
14-
},
156
"additionalProperties": false
167
}

src/lnav.events.cc

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ const string_fragment open::SCHEMA_ID
4040
= "https://lnav.org/event-file-open-v1.schema.json"_frag;
4141

4242
const typed_json_path_container<open> open::handlers = typed_json_path_container<open>{
43-
yajlpp::property_handler("$schema").for_field(&open::o_schema)
44-
.with_const(SCHEMA_ID),
4543
yajlpp::property_handler("filename")
4644
.with_description("The path of the file that was opened")
4745
.for_field(&open::o_filename),
@@ -53,8 +51,6 @@ const string_fragment format_detected::SCHEMA_ID
5351
= "https://lnav.org/event-file-format-detected-v1.schema.json"_frag;
5452

5553
const typed_json_path_container<format_detected> format_detected::handlers = typed_json_path_container<format_detected>{
56-
yajlpp::property_handler("$schema").for_field(&format_detected::fd_schema)
57-
.with_const(SCHEMA_ID),
5854
yajlpp::property_handler("filename")
5955
.with_description("The path of the file for which a matching format was found")
6056
.for_field(&format_detected::fd_filename),
@@ -79,8 +75,6 @@ static const json_path_container msg_values_handlers = {
7975
};
8076

8177
const typed_json_path_container<msg_detected> msg_detected::handlers = typed_json_path_container<msg_detected>{
82-
yajlpp::property_handler("$schema").for_field(&msg_detected::md_schema)
83-
.with_const(SCHEMA_ID),
8478
yajlpp::property_handler("watch-name")
8579
.with_description("The name of the watch expression that matched this log message")
8680
.for_field(&msg_detected::md_watch_name),
@@ -110,12 +104,10 @@ namespace session {
110104
const string_fragment loaded::SCHEMA_ID
111105
= "https://lnav.org/event-session-loaded-v1.schema.json"_frag;
112106

113-
const typed_json_path_container<loaded> loaded::handlers = typed_json_path_container<loaded>{
114-
yajlpp::property_handler("$schema").for_field(&loaded::l_schema)
115-
.with_example(SCHEMA_ID),
116-
}
117-
.with_schema_id2(SCHEMA_ID)
118-
.with_description2("Event fired when a session is loaded.");
107+
const typed_json_path_container<loaded> loaded::handlers
108+
= typed_json_path_container<loaded>{}
109+
.with_schema_id2(SCHEMA_ID)
110+
.with_description2("Event fired when a session is loaded.");
119111

120112
} // namespace session
121113

src/yajlpp/yajlpp.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,6 +1322,10 @@ yajlpp_gen_context::gen()
13221322
{
13231323
yajlpp_map root(this->ygc_handle);
13241324

1325+
if (!this->ygc_handlers->jpc_schema_id.empty()) {
1326+
root.gen("$schema");
1327+
root.gen(this->ygc_handlers->jpc_schema_id);
1328+
}
13251329
for (const auto& jph : this->ygc_handlers->jpc_children) {
13261330
jph.gen(*this, this->ygc_handle);
13271331
}

test/expected/test_cli.sh_0b3639753916f71254e8c9cce4ebb8bfd9978d3e.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"$schema": "https://lnav.org/schemas/config-v1.schema.json",
23
"apps": {
34
"lnav": {
45
"api-test": {

0 commit comments

Comments
 (0)