Skip to content

Commit

Permalink
Specify implementation-specific metadata
Browse files Browse the repository at this point in the history
(version, name, language, possibly more).
  • Loading branch information
Julian committed Sep 8, 2022
1 parent c06ed0e commit 76b062f
Show file tree
Hide file tree
Showing 14 changed files with 205 additions and 45 deletions.
16 changes: 13 additions & 3 deletions implementations/dotnet-json-everything/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,17 @@
throw new UnknownVersion(version);
}
Started = true;
Console.Out.WriteLine("{\"ready\": true, \"version\": 1}");
JsonObject StartResult = new JsonObject
{
["ready"] = true,
["version"] = 1,
["implementation"] = new JsonObject
{
["language"] = "dotnet",
["name"] = "json-everything",
},
};
Console.Out.WriteLine(StartResult);
break;

case "run":
Expand All @@ -50,12 +60,12 @@
results.Add(testResult);
};

JsonObject result = new JsonObject
JsonObject RunResult = new JsonObject
{
["seq"] = root.GetProperty("seq").GetInt64(),
["results"] = results,
};
Console.Out.WriteLine(result);
Console.Out.WriteLine(RunResult);
break;

case "stop":
Expand Down
4 changes: 4 additions & 0 deletions implementations/go-jsonschema/bowtie_jsonschema.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ func main() {
data := map[string]interface{}{
"ready": true,
"version": 1,
"implementation": map[string]interface{}{
"language": "go",
"name": "jsonschema",
},
}

if err := encoder.Encode(&data); err != nil {
Expand Down
9 changes: 8 additions & 1 deletion implementations/js-ajv/bowtie_ajv.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ const cmds = {
start: (args) => {
console.assert(args.version === 1, { args });
started = true;
return {ready: true, version: 1}
return {
ready: true,
version: 1,
implementation: {
language: 'javascript',
name: 'ajv',
},
}
},

run: (args) => {
Expand Down
9 changes: 8 additions & 1 deletion implementations/js-hyperjump/bowtie_hyperjump.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ const cmds = {
start: async (args) => {
console.assert(args.version === 1, { args });
started = true;
return {ready: true, version: 1}
return {
ready: true,
version: 1,
implementation: {
language: 'javascript',
name: 'hyperjump-jsv',
},
}
},

run: async (args) => {
Expand Down
9 changes: 8 additions & 1 deletion implementations/lua-jsonschema/bowtie-jsonschema
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@ local cmds = {
start = function(request)
assert(request.version == 1, "Wrong version!")
STARTED = true
return { ready = true, version = 1 }
return {
ready = true,
version = 1,
implementation = {
language = 'lua',
name = 'jsonschema',
}
}
end,
run = function(request)
assert(STARTED, "Not started!")
Expand Down
11 changes: 10 additions & 1 deletion implementations/python-fastjsonschema/bowtie-fastjsonschema
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
from dataclasses import dataclass
from importlib import metadata
import io
import json
import sys
Expand All @@ -25,7 +26,15 @@ class Runner:
def cmd_start(self, version):
assert version == 1
self._started = True
return dict(ready=True, version=1)
return dict(
ready=True,
version=1,
implementation=dict(
language="python",
name="fastjsonschema",
version=metadata.version("fastjsonschema"),
),
)

def cmd_run(self, case, seq):
assert self._started, "Not started!"
Expand Down
11 changes: 10 additions & 1 deletion implementations/python-jsonschema/bowtie-jsonschema
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
from dataclasses import dataclass
from importlib import metadata
import io
import json
import sys
Expand All @@ -25,7 +26,15 @@ class Runner:
def cmd_start(self, version):
assert version == 1
self._started = True
return dict(ready=True, version=1)
return dict(
ready=True,
version=1,
implementation=dict(
language="python",
name="jsonschema",
version=metadata.version("jsonschema"),
),
)

def cmd_run(self, case, seq):
assert self._started, "Not started!"
Expand Down
9 changes: 8 additions & 1 deletion implementations/rust-jsonschema/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@ fn main() -> Result<()> {
if request["version"] != 1 {
panic!("Not version 1!")
};
let response = json!({"ready": true, "version": 1});
let response = json!({
"ready": true,
"version": 1,
"implementation": {
"language": "rust",
"name": "jsonschema",
}
});
println!("{}", response.to_string());
}
"run" => {
Expand Down
68 changes: 52 additions & 16 deletions io-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,60 @@

"$defs": {
"start": {
"description": "Sent once at program start to the implementation to indicate Bowtie is starting to send test cases. Response should indicate the implementation is ready.",
"description": "Sent once at program start to the implementation to indicate Bowtie is starting to send test cases.",

"type": "object",
"required": ["version"],
"properties": {
"cmd": { "const": "start" },
"version": { "$ref": "#/$defs/version" }
"version": {
"description": "The version of the Bowtie protocol which is intended.",
"$ref": "#/$defs/version"
}
},
"$defs": {
"response": {
"type": "object",
"required": ["ready", "version", "implementation"],
"properties": {
"ready": { "type": "boolean" },
"version": { "$ref": "#/$defs/version" }
"ready": {
"description": "Confirmation that the implementation is ready.",
"const": true
},
"version": {
"description": "Confirmation of the Bowtie version",
"$ref": "#/$defs/version"
},
"implementation": {
"description": "Metadata about the implementation. The below properties are encouraged, but additional metadata can also be passed",
"type": "object",
"properties": {
"language": {
"description": "The implementation language (e.g. C++, Python, etc.)",
"type": "string"
},
"name": {
"description": "The name of the implementation itself",
"type": "string"
},
"version": {
"description": "The implementation version",
"type": "string"
}
}
}
}
}
}
},

"run": {
"description": "Sent to implementations for each test case. Responses should include the result of validation.",
"description": "Sent to implementations for each test case.",

"type": "object",
"required": ["seq", "case"],
"properties": {
"cmd": { "const": "run" },
"seq": {
"description": "A sequence identifier for the test case. It must be passed along as-is in the response."
"description": "A sequence identifier for the test case. It must be passed along as-is in the response."
},
"case": { "$ref": "#/$defs/case" }
},
Expand All @@ -61,9 +87,15 @@
}
},
"oneOf": [
{ "$ref": "#/$defs/command/$defs/run/$defs/response/$defs/result" },
{ "$ref": "#/$defs/command/$defs/run/$defs/response/$defs/skipped" },
{ "$ref": "#/$defs/command/$defs/run/$defs/response/$defs/errored" }
{
"$ref": "#/$defs/command/$defs/run/$defs/response/$defs/result"
},
{
"$ref": "#/$defs/command/$defs/run/$defs/response/$defs/skipped"
},
{
"$ref": "#/$defs/command/$defs/run/$defs/response/$defs/errored"
}
],
"$defs": {
"result": {
Expand All @@ -83,8 +115,12 @@
"required": ["valid"],
"additionalProperties": false
},
{ "$ref": "#/$defs/command/$defs/run/$defs/response/$defs/skipped" },
{ "$ref": "#/$defs/command/$defs/run/$defs/response/$defs/errored" }
{
"$ref": "#/$defs/command/$defs/run/$defs/response/$defs/skipped"
},
{
"$ref": "#/$defs/command/$defs/run/$defs/response/$defs/errored"
}
]
}
}
Expand All @@ -95,7 +131,7 @@

"required": ["skipped"],
"properties": {
"skipped": {"const": true},
"skipped": { "const": true },
"message": {
"description": "A human-readable message passed back from the implementation explaining why the skip occurred.",
"type": "string"
Expand All @@ -113,7 +149,7 @@

"required": ["errored"],
"properties": {
"errored": {"const": true},
"errored": { "const": true },
"context": {
"description": "Additional implementation-specific or language-specific context available when the error was caught."
}
Expand All @@ -127,7 +163,7 @@

"stop": {
"description": "Sent once at program end to the implementation to indicate it should shut down.",
"type": "object",

"properties": {
"cmd": { "const": "stop" }
},
Expand Down
9 changes: 8 additions & 1 deletion tests/fauxmplementations/badsonschema/badsonschema
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,14 @@ class Runner:
assert version == 1

self._started = True
return dict(ready=True, version=1)
return dict(
ready=True,
version=1,
implementation=dict(
language="python",
name="badsonschema",
),
)

def cmd_run(self, case, seq):
assert self._started, "Not started!"
Expand Down
9 changes: 8 additions & 1 deletion tests/fauxmplementations/cheatsonschema/cheatsonschema
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@ class Runner:
def cmd_start(self, version):
assert version == 1
self._started = True
return dict(ready=True, version=1)
return dict(
ready=True,
version=1,
implementation=dict(
language="python",
name="cheatsonschema",
),
)

def cmd_run(self, case, seq):
assert self._started, "Not started!"
Expand Down
9 changes: 8 additions & 1 deletion tests/fauxmplementations/envsonschema/envsonschema
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,14 @@ class Runner:

assert version == 1
self._started = True
self.send(ready=True, version=1)
self.send(
ready=True,
version=1,
implementation=dict(
language="python",
name="envsonschema",
),
)

def cmd_run(self, case, seq):
assert self._started, "Not started!"
Expand Down
Loading

0 comments on commit 76b062f

Please sign in to comment.