Skip to content

Commit

Permalink
fix: JSON Schema fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rhwood committed Mar 11, 2020
1 parent 916c0c4 commit 16e89ed
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 18 deletions.
Expand Up @@ -28,7 +28,12 @@ public class JsonOperationsServiceFactory implements JsonServiceFactory<JsonOper

@Override
public String[] getTypes(String version) {
return new String[]{CAR, CARS, CAR_TYPE, ENGINE, ENGINES, KERNEL, LOCATION, LOCATIONS, ROLLING_STOCK, TRACK, TRAIN, TRAINS};
return new String[]{CAR, CARS, CAR_TYPE, ENGINE, ENGINES, KERNEL, LOCATION, LOCATIONS, TRACK, TRAIN, TRAINS};
}

@Override
public String[] getSentTypes(String version) {
return new String[]{ROLLING_STOCK};
}

@Override
Expand Down
6 changes: 3 additions & 3 deletions java/src/jmri/server/json/operations/train-server.json
Expand Up @@ -33,15 +33,15 @@
"description": "Human readable train status"
},
"statusCode": {
"type": "int",
"type": "integer",
"description": "Machine readable train status"
},
"length": {
"type": "int",
"type": "integer",
"description": "Current train length"
},
"weight": {
"type": "int",
"type": "integer",
"description": "Current train weight"
},
"caboose": {
Expand Down
2 changes: 1 addition & 1 deletion java/src/jmri/server/json/util/JsonUtilHttpService.java
Expand Up @@ -730,7 +730,6 @@ public JsonNode doSchema(String type, boolean server, JsonRequest request) throw
case JsonException.ERROR:
case JSON.LIST:
case JSON.PONG:
case JSON.VERSION:
if (server) {
return doSchema(type, server,
this.mapper.readTree(this.getClass().getClassLoader()
Expand All @@ -756,6 +755,7 @@ public JsonNode doSchema(String type, boolean server, JsonRequest request) throw
case JSON.METADATA:
case JSON.NODE:
case JSON.RAILROAD:
case JSON.VERSION:
return doSchema(type,
server,
RESOURCE_PATH + type + "-server.json",
Expand Down
14 changes: 3 additions & 11 deletions java/src/jmri/server/json/util/JsonUtilServiceFactory.java
Expand Up @@ -8,7 +8,6 @@
import org.openide.util.lookup.ServiceProvider;

/**
*
* @author Randall Wood
*/
@ServiceProvider(service = JsonServiceFactory.class)
Expand All @@ -30,29 +29,22 @@ public String[] getTypes(String version) {
JSON.CONFIG_PROFILE,
JSON.CONFIG_PROFILES,
JSON.VERSION
};
};
}

@Override
public String[] getSentTypes(String version) {
// retain ERROR on behalf of JsonException for schema handling
// retain LIST on behalf of JSON servers for schema handling
// retain PONG on behalf of JSON servers for schema handling
return new String[]{JsonException.ERROR,
JSON.CONFIG_PROFILE,
JSON.LIST,
JSON.NETWORK_SERVICE,
JSON.PANEL,
JSON.PONG,
JSON.SYSTEM_CONNECTION};
return new String[]{JsonException.ERROR, JSON.LIST, JSON.PONG};
}

@Override
public String[] getReceivedTypes(String version) {
// retain LOCALE on behalf of JSON servers for schema handling
// retain PING on behalf of JSON servers for schema handling
return new String[]{JSON.LOCALE,
JSON.PING};
return new String[]{JSON.LOCALE, JSON.PING};
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion java/src/jmri/server/json/util/list-server.json
@@ -1,6 +1,6 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "jmri-json-server-list",
"title": "jmri-json-list-server-message",
"type": "array",
"description": "List of objects from JMRI to client"
}
9 changes: 9 additions & 0 deletions java/src/jmri/server/json/util/version-client.json
@@ -0,0 +1,9 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "jmri-json-version-client-message",
"type": "object",
"description": "Schema data object in message from client to JMRI for type \"version\"",
"properties": {
},
"additionalProperties": false
}
2 changes: 1 addition & 1 deletion java/src/jmri/server/json/util/version-server.json
@@ -1,6 +1,6 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "jmri-json-server-version-message",
"title": "jmri-json-version-server-message",
"type": "object",
"description": "Data portion of message from JMRI to client for type \"version\"; property names are version numbers in major.minor.patch form; property values are the RESTful URL portion for that version"
}

0 comments on commit 16e89ed

Please sign in to comment.