Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add jsonschema exporter for VSS. #296

Merged
merged 10 commits into from
Oct 19, 2023
Merged

Conversation

adobekan
Copy link
Collaborator

Work still in progress.

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

}

def add_arguments(parser: argparse.ArgumentParser):
parser.description = "The JSON schema exporter does not support any additional arguments."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we possibly have --json-pretty similar to vspec2json?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i guess it should work same as for JSON.

@adobekan
Copy link
Collaborator Author

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

@erikbosch
Copy link
Collaborator

Meeting notes:

  • Sebastian: Think this should be in 4.1, can volunteer if Adnan has no time
  • Adnan: lets do it together

@erikbosch
Copy link
Collaborator

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

@erikbosch
Copy link
Collaborator

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
Copy link
Collaborator

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

@erikbosch erikbosch added the Status:WorkInProgress Someone is actively working on changing/extending this PR label Sep 20, 2023
@SebastianSchildt
Copy link
Collaborator

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
Copy link
Collaborator

Added basic tests

@adobekan
Copy link
Collaborator Author

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.

adobekan and others added 9 commits September 22, 2023 18:53
Signed-off-by: Sebastian Schildt <[email protected]>
Signed-off-by: Adnan Bekan <[email protected]>
Signed-off-by: Sebastian Schildt <[email protected]>
Signed-off-by: Adnan Bekan <[email protected]>
Signed-off-by: Adnan Bekan <[email protected]>
Signed-off-by: Sebastian Schildt <[email protected]>
@erikbosch
Copy link
Collaborator

Meeting notes:

  • Adnan and Sebastian has done a lot of work
  • TODO: Read readme.
  • Please review. Focus on output format, check if ok
  • Could be great if Krishna run it with some struct setup to see if it works with structs and looks reasonable

@erikbosch erikbosch added the Status:Review Please review/discuss contents label Sep 26, 2023
Signed-off-by: Sebastian Schildt <[email protected]>
@SebastianSchildt
Copy link
Collaborator

Added documentation.

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

Will investigate

@adobekan
Copy link
Collaborator Author

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
Copy link
Collaborator

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

@SebastianSchildt SebastianSchildt marked this pull request as ready for review October 17, 2023 13:40
@erikbosch
Copy link
Collaborator

Meeting notes:

  • Merge

@erikbosch erikbosch added Status:Approved and removed Status:WorkInProgress Someone is actively working on changing/extending this PR Status:Review Please review/discuss contents labels Oct 19, 2023
@erikbosch erikbosch merged commit 2d0b544 into COVESA:master Oct 19, 2023
6 checks passed
erikbosch pushed a commit to boschglobal/vss-tools that referenced this pull request Nov 14, 2023
* Add jsonschema exporter for VSS.

Signed-off-by: Adnan Bekan <[email protected]>
Signed-off-by: Sebastian Schildt <[email protected]>
erikbosch pushed a commit that referenced this pull request Nov 14, 2023
* Add jsonschema exporter for VSS.

Signed-off-by: Adnan Bekan <[email protected]>
Signed-off-by: Sebastian Schildt <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants