Skip to content

Commit

Permalink
[API Part2] Updated JSON encoding req class
Browse files Browse the repository at this point in the history
  • Loading branch information
alexrobin committed Jun 12, 2024
1 parent e16c8a6 commit 438bf3c
Show file tree
Hide file tree
Showing 5 changed files with 136 additions and 55 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"datastream@link": {
"href": "https://data.example.org/api/datastreams/445ssdf55",
"title": "Plume Simulation Data",
"type": "application/json"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"inline": {
"mean": "10.51",
"stdev": "1.23"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"observation@link": {
"href": "https://data.example.org/api/observations/gss45sdf413s387g49445ssdf55?f=json",
"title": "Satellite Image",
"type": "application/json"
}
}
17 changes: 16 additions & 1 deletion api/part2/standard/23-002r0.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,23 @@
:commandresult-resources-endpoint: <<clause-commandresult-resources-endpoint,Command Result resources endpoint>>
:systemevent-resources-endpoint: <<clause-systemevent-resources-endpoint,System Event resources endpoint>>
//
:jsonschema-base-url: https://raw.githubusercontent.com/opengeospatial/connected-systems/master/api/part2/openapi/schemas
:filter-idlist-schema: link:https://docs.ogc.org/DRAFTS/23-001r0.html#filter-idlist-schema[ID_List]
//:json-schema-root: https://raw.githubusercontent.com/opengeospatial/connected-systems/master/api/part2/openapi/schemas/json
:json-schema-root: ./openapi/schemas/json
:json-datastream-schema: link:{json-schema-root}/dataStream.json[dataStream.json]
:json-datastream-collection-schema: link:{json-schema-root}/dataStreamCollection.json[dataStreamCollection.json]
:json-observation-schema: link:{json-schema-root}/observation.json[observation.json]
:json-observation-collection-schema: link:{json-schema-root}/observationCollection.json[observationCollection.json]
:json-controlstream-schema: link:{json-schema-root}/controlStream.json[controlStream.json]
:json-controlstream-collection-schema: link:{json-schema-root}/controlStreamCollection.json[controlStreamCollection.json]
:json-command-schema: link:{json-schema-root}/command.json[command.json]
:json-command-collection-schema: link:{json-schema-root}/commandCollection.json[commandCollection.json]
:json-commandstatus-schema: link:{json-schema-root}/commandStatus.json[commandStatus.json]
:json-commandstatus-collection-schema: link:{json-schema-root}/commandStatusCollection.json[commandStatusCollection.json]
:json-commandresult-schema: link:{json-schema-root}/commandResult.json[commandResult.json]
:json-commandresult-collection-schema: link:{json-schema-root}/commandResultCollection.json[commandResultCollection.json]
:json-systemevent-schema: link:{json-schema-root}/systemEvent.json[systemEvent.json]
:json-systemevent-collection-schema: link:{json-schema-root}/systemEventCollection.json[systemEventCollection.json]

////
Make sure to complete each included document
Expand Down
Original file line number Diff line number Diff line change
@@ -1,41 +1,55 @@
:json-schema-root: ../openapi/schemas/json
:json-mediatype: application/json


[[clause-encoding-json]]
=== Requirements Class "JSON Encoding"
include::../requirements/encoding/json/requirements_class_json.adoc[]


==== Overview
include::../requirements/encoding/json/requirements_class_json.adoc[]

This requirements class defines general JSON encodings for all resource types defined in part 2.
This encoding must be supported by all implementations.


==== Media Type

The media type to use to advertise support for this encoding is `application/json`.
The media type used to advertise support for this encoding is `{json-mediatype}`.

[requirement,model=ogc]
====
[%metadata]
identifier:: /req/json/mediatype-read
The server SHALL support the media type `{json-mediatype}` in the HTTP `Accept` header and respond with a JSON document corresponding to the requested resource type.
====

[requirement,model=ogc]
====
[%metadata]
identifier:: /req/json/mediatype-write
conditions:: The server implements <<clause-resource-crd,style=basic%>>.
The server SHALL support the media type `{json-mediatype}` in the HTTP `Content-Type` header and parse the JSON body according to the resource type.
====


[[clause-json-datastream]]
==== Datastream Encoding Rules

The `Datastream` resource is encoded as a JSON object. JSON members have the same names as the class properties and associations. Associations are implemented as links.
[requirement,model=ogc]
====
[%metadata]
identifier:: /req/json/datastream-schema
[[req_json-schema-datastream]]
[width="90%",cols="2,6a",options="header"]
|===
^|*Requirement {counter:req-id}* |*/req/encoding/json/datastream-schema*
^| Condition | Server implements <<clause-datastreams,style=basic%>>.
^| A | A 200-response with the media type `application/json` containing `Datastream` resources SHALL conform to one of the following schemas:
part:: A JSON document containing a single `DataStream` resource SHALL be valid against the JSON schema {json-datastream-schema}.
- link:{json-schema-root}/datastreamCollection.json[datastreamCollection.json] for a collection of datastreams, and
- link:{json-schema-root}/datastream.json[datastream.json] for a single datastream.
|===
part:: A JSON document containing a collection of `DataStream` resources SHALL be valid against the JSON schema {json-datastream-collection-schema}.
====

[[example_json_datastream1]]
.A Datastream in JSON format
=================
This is a simple datastream with a single observed property and a single format.
This is a simple datastream with a single observed property.
[source%autofit,json]
----
Expand All @@ -55,16 +69,15 @@ When using the plain `application/json` media type for retrieving observations,
[[clause-json-observation]]
==== Observation Encoding Rules

[[req_json-schema-observation]]
[width="90%",cols="2,6a",options="header"]
|===
^|*Requirement {counter:req-id}* |*/req/encoding/json/observation-schema*
^| Condition | Server implements <<clause-datastreams,style=basic%>>.
^| A | A 200-response with the media type `application/json` containing `Observation` resources SHALL conform to one of the following schemas:
[requirement,model=ogc]
====
[%metadata]
identifier:: /req/json/observation-schema
part:: A JSON document containing a single `Observation` resource SHALL be valid against the JSON schema {json-observation-schema}.
- link:{json-schema-root}/observationCollection.json[observationCollection.json] for a collection of observations, and
- link:{json-schema-root}/observation.json[observation.json] for a single observation.
|===
part:: A JSON document containing a collection of `Observation` resources SHALL be valid against the JSON schema {json-observation-collection-schema}.
====

[[example_json_obs]]
.Observations in JSON format
Expand All @@ -89,18 +102,15 @@ include::../openapi/examples/observations/obs-location.json[]
[[clause-json-controlstream]]
==== Control Stream Encoding Rules

The `ControlStream` resource is encoded as a JSON object. JSON members have the same names as the class properties and associations. Associations are implemented as links.
[requirement,model=ogc]
====
[%metadata]
identifier:: /req/json/controlstream-schema
[[req_json-schema-controlstream]]
[width="90%",cols="2,6a",options="header"]
|===
^|*Requirement {counter:req-id}* |*/req/encoding/json/controlstream-schema*
^| Condition | Server implements <<clause-controlstreams,style=basic%>>.
^| A | A 200-response with the media type `application/json` containing `ControlStream` resources SHALL conform to one of the following schemas:
part:: A JSON document containing a single `ControlStream` resource SHALL be valid against the JSON schema {json-controlstream-schema}.
- link:{json-schema-root}/controlStreamCollection.json[controlStreamCollection.json] for a collection of control streams, and
- link:{json-schema-root}/controlStream.json[controlStream.json] for a single control stream.
|===
part:: A JSON document containing a collection of `ControlStream` resources SHALL be valid against the JSON schema {json-controlstream-collection-schema}.
====

[[example_json_controlstream1]]
.A Control Stream in JSON format
Expand All @@ -118,16 +128,15 @@ include::../openapi/examples/controlstreams/controlStream-ptz.json[]
[[clause-json-command]]
==== Command Encoding Rules

[[req_json-schema-command]]
[width="90%",cols="2,6a",options="header"]
|===
^|*Requirement {counter:req-id}* |*/req/encoding/json/command-schema*
^| Condition | Server implements <<clause-controlstreams,style=basic%>>.
^| A | A 200-response with the media type `application/json` containing `Command` resources SHALL conform to one of the following schemas:
[requirement,model=ogc]
====
[%metadata]
identifier:: /req/json/command-schema
- link:{json-schema-root}/commandCollection.json[commandCollection.json] for a collection of commands, and
- link:{json-schema-root}/command.json[command.json] for a single command.
|===
part:: A JSON document containing a single `Command` resource SHALL be valid against the JSON schema {json-command-schema}.
part:: A JSON document containing a collection of `Command` resources SHALL be valid against the JSON schema {json-command-collection-schema}.
====

[[example_json_command]]
.Command in JSON format
Expand All @@ -145,19 +154,18 @@ include::../openapi/examples/commands/command-ptz.json[]
[[clause-json-commandstatus]]
==== Command Status Encoding Rules

[[req_json-schema-command-status]]
[width="90%",cols="2,6a",options="header"]
|===
^|*Requirement {counter:req-id}* |*/req/encoding/json/command-status-schema*
^| Condition | Server implements <<clause-controlstreams,style=basic%>>.
^| A | A 200-response with the media type `application/json` containing `CommandStatus` resources SHALL conform to one of the following schemas:
[requirement,model=ogc]
====
[%metadata]
identifier:: /req/json/commandstatus-schema
part:: A JSON document containing a single `CommandStatus` resource SHALL be valid against the JSON schema {json-commandstatus-schema}.
- link:{json-schema-root}/commandStatusCollection.json[commandStatusCollection.json] for a collection of command status reports, and
- link:{json-schema-root}/commandStatus.json[commandStatus.json] for a single command status report.
|===
part:: A JSON document containing a collection of `CommandStatus` resources SHALL be valid against the JSON schema {json-commandstatus-collection-schema}.
====

[[example_json_command_status]]
.Command status in JSON format
.Command Status in JSON format
=================
These are example command status reports, encoded in JSON format:
Expand All @@ -177,9 +185,47 @@ include::../openapi/examples/commandStatus/command-status-completed.json[]
[[clause-json-commandresult]]
==== Command Result Encoding Rules

[requirement,model=ogc]
====
[%metadata]
identifier:: /req/json/commandresult-schema
part:: A JSON document containing a single `CommandResult` resource SHALL be valid against the JSON schema {json-commandresult-schema}.
part:: A JSON document containing a collection of `CommandResult` resources SHALL be valid against the JSON schema {json-commandresult-collection-schema}.
====

[[example_json_command_result]]
.Command Result in JSON format
=================
These are example command status reports, encoded in JSON format:
[source%autofit,json]
----
include::../openapi/examples/commandResult/command-result-inline.json[]
----
[source%autofit,json]
----
include::../openapi/examples/commandResult/command-result-single-obs.json[]
----
[source%autofit,json]
----
include::../openapi/examples/commandResult/command-result-datastream.json[]
----
=================


[[clause-json-systemevent]]
==== System Event Encoding Rules

[requirement,model=ogc]
====
[%metadata]
identifier:: /req/json/systemevent-schema
part:: A JSON document containing a single `SystemEvent` resource SHALL be valid against the JSON schema {json-systemevent-schema}.
part:: A JSON document containing a collection of `SystemEvent` resources SHALL be valid against the JSON schema {json-systemevent-collection-schema}.
====

0 comments on commit 438bf3c

Please sign in to comment.