COVESA / vss-tools

Software for working with VSS (https://github.com/COVESA/vehicle_signal_specification)
Mozilla Public License 2.0
51 stars 55 forks source link

Add jsonschema exporter for VSS. #296

Closed adobekan closed 10 months ago

adobekan commented 1 year ago

Work still in progress.

to try, ./vspec2jsonschema.py ../spec/VehicleSignalSpecification.vspec ../../mydemo.schema.json

adobekan commented 1 year ago

Here is an OpenAPI example as well

openapi: 3.1.0
info:
  title: Vehicle Acceleration API
  version: 1.0.1
servers:
  - url: https://api.accelerationservice.com/v1

paths:
  /vehicle/acceleration:
    post:
      summary: Provide Vehicle Acceleration Data
      description: Endpoint to send vehicle acceleration data.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: schema/mydemo_vehicle.schema.json#/Vehicle/$children/Acceleration
      responses:
        '200':
          description: Success. Acceleration data received.
        '400':
          description: Bad Request. Invalid payload or data format.

  /vehicle/acceleration/mySpecificLocationEvent:
    get:
      summary: Get Current Vehicle Data
      description: Get the current location and acceleration data of the vehicle.
      responses:
        '200':
          description: Success. Current vehicle data received.
          content:
            application/json:
              schema:
                type: object
                properties:
                  Location:
                    $ref: schema/mydemo_vehicle.schema.yaml#/Vehicle/$children/CurrentLocation
                  Acceleration:
                    $ref: schema/mydemo_vehicle.schema.yaml#/Vehicle/$children/Acceleration

  /vehicle/acceleration/TriggerService:
    get:
      summary: Get Current Vehicle Data
      description: Get the current location and acceleration data of the vehicle.
      parameters:
        - name: longitudinal_threshold
          in: query
          description: Threshold for longitudinal acceleration (X-axis) in m/s^2.
          schema:
            type: number
        - name: lateral_threshold
          in: query
          description: Threshold for lateral acceleration (Y-axis) in m/s^2.
          schema:
            type: number
      responses:
        '200':
          description: Success. Current vehicle data received.
          content:
             application/json:
              schema:
                type: object
                properties:
                  Timestamp:
                    type: string
                    format: date-time
                    description: The timestamp of the vehicle data.
                  Location:
                    $ref: schema/mydemo_vehicle.schema.yaml#/Vehicle/$children/CurrentLocation
                  Acceleration:
                    $ref: schema/mydemo_vehicle.schema.yaml#/Vehicle/$children/Acceleration
SebastianSchildt commented 1 year ago

See also https://wiki.covesa.global/display/WIK4/Data+Expert+Group+Workshops+-+Interface+Pillar+Alignment?preview=/71073952/75727000/COVESA_VSS_OpenAPI.pdf

SebastianSchildt commented 1 year ago

https://wiki.covesa.global/display/WIK4/Data+Expert+Group+Workshops+-+Interface+Pillar+Alignment

erikbosch commented 12 months ago

Meeting notes:

erikbosch commented 11 months ago

Commit sha: 0dc6a7f, Author: Adnan Bekan, Committer: Adnan Bekan; The sign-off is missing.

erikbosch commented 11 months ago

Two things I would like to have before merging it:

Another topic - do we want it to be included as a future release artifact? If so we should better update https://github.com/COVESA/vehicle_signal_specification/wiki/Release-Instructions-and-Checklist#create-output-artifacts and possibly the VSS Makefile as well to include it in builds/releases, but that can be done after this PR is merged

SebastianSchildt commented 11 months ago

I agree on the tests and setup.py, currently however I do think this tool does not work correctly yet. It seems to create something that is almost but not entirely unlike a json schema

Investigating

SebastianSchildt commented 11 months ago

The code dod not work with models that do not have Vehicle in the root (such as test cases and probably EV charging group. Fixed it)

SebastianSchildt commented 11 months ago

Added basic tests

adobekan commented 11 months ago

The code dod not work with models that do not have Vehicle in the root (such as test cases and probably EV charging group. Fixed it)

Here i was

The code dod not work with models that do not have Vehicle in the root (such as test cases and probably EV charging group. Fixed it)

Was thinking about this one even in the case if you are defining API for only specific domain. Great.

erikbosch commented 11 months ago

Meeting notes:

SebastianSchildt commented 10 months ago

Added documentation.

--extended-attributes , -e seems to be broken, seems to only works with --jsonschema-all-extended-attributes

Will investigate

adobekan commented 10 months ago

Added documentation.

--extended-attributes , -e seems to be broken, seems to only works with --jsonschema-all-extended-attributes

Will investigate

Did not try that option. Could it be space where it was defined, maybe we have some overlapping with other tools?

SebastianSchildt commented 10 months ago

Well. It works..... I think I mixed up some files when checking before. Marking this ready to review (or merge imo)

erikbosch commented 10 months ago

Meeting notes: