Skip to content

JSON Schema

vinay0000 edited this page Feb 7, 2024 · 4 revisions

This page outlines the approach to use JSON schema for providing an user-interface for the python-based packages. It is based on the work by Prof Paul Grogan on the TAT-C and NOS-T projects.

From Paul's email correspondence

Primary supporting libraries:

pydantic is the base utility that helps interchange Python objects and JSON objects (with data typing/validation).

geojson-pydantic supplies some of the pydantic schemas conforming to the GeoJSON standard.

Others:

typing, typing_extensions, enum, uuid

fastapi_utils provides the APIModel schema which helps align schemas with web APIs. For example, pythonic convention uses snake case for variables (my_attribute) while web services more commonly use camel case (myAttribute) – APIModel automatically provides aliases for all snake case variables. There may be some other benefits bit it is largely for ease of use rather than new functionality.

**functionality is (in order of importance): **

  1. serialization/deserialization from JSON,
  2. validation checks,
  3. code interfaces that specify required/expected functions.

#1 helps define interoperability standards (data must be serialized to be exchanged between hosts). #2 helps refine the specific syntax allowed/disallowed. #3 helps with internal development.

pydantic is the base utility that helps interchange Python objects and JSON objects (with data typing/validation).

geojson-pydantic supplies some of the pydantic schemas conforming to the GeoJSON standard.

fastapi_utils provides the APIModel schema which helps align schemas with web APIs. For example, pythonic convention uses snake case for variables (my_attribute) while web services more commonly use camel case (myAttribute) – APIModel automatically provides aliases for all snake case variables. There may be some other benefits bit it is largely for ease of use rather than new functionality.

Implementation

In TAT-C, the src/tatc folder is for the Python library; app/ is source code for the web service application which relies on the core TAT-C library. So src/tatc/schemas are all of the base objects independent of any particular application and app/tatc_app/... contains additional schemas for the HTTP web services described here https://tatc.code-lab.org/docs

For NOS-T, nost_tools/ is the root directory for the library (functionally similar to src/tatc) and examples/ has some example applications that rely on the base library. The nost_tools/schemas.py defines base schemas for messages exchanged between applications. Any example application will need application-specific events that could also be defined with other schemas to establish a standard format.

Relevant publication: Paul T. Grogan, Josue I. Tapiaa, "Using JSON Schema to define a system modeling vocabulary: The Tradespace Analysis Tool for Constellations (TAT-C)", 2023 Conference on Systems Engineering Research. Grogan_CSER23_TATC.pdf

Clone this wiki locally