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

#1: schemas for DD and WebAPI configs #2

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

mohit-s96
Copy link
Member

Closes #1

Adds configs for DD and WebAPI.

Sample WebAPI report that can be validated using the WebAPI schema:

{
  "endorsement": "web-api-server-core",
  "version": "2.0.0",
  "providerUoi": "M00000001",
  "providerUsi": "50024",
  "recipientUoi": "T00000052",
  "recipientEmail": "[email protected]",
  "serviceRootUri": "www.serviceRootUri.com",
   "clientCredentials": {
    "clientId": "1233456",
    "clientSecret": "123123abc",
    "tokenUri": "uri.com",
    "scope": "scope"
  },
  "parameters": [
    { "name": "Resource", "value": "Property", "defaultValue": "DefProoperty" },
    {
      "name": "Key Field",
      "value": "ListingKey",
      "defaultValue": "DeftListing"
    },
    {
      "name": "Integer Field",
      "value": "BedroomsTotal",
      "defaultValue": "DefBedroomsTotal"
    },
    {
      "name": "Decimal Field",
      "value": "ListPrice",
      "defaultValue": "DefListValue"
    },
    {
      "name": "Single Lookup Field",
      "value": "StandardStatus",
      "defaultValue": "DefStandardStatus"
    },
    {
      "name": "Single Lookup Value",
      "value": "Active",
      "defaultValue": "DefLookupValueAct"
    },
    {
      "name": "Multi Lookup Field",
      "value": "Basement",
      "defaultValue": "Defbasement"
    },
    {
      "name": "Multi Lookup Value 1",
      "value": "Apartment",
      "defaultValue": "DefApartment"
    },
    {
      "name": "Multi Lookup Value 2",
      "value": "Block",
      "defaultValue": "DefLookup"
    },
    {
      "name": "Date Field",
      "value": "ListingContractDate",
      "defaultValue": "DefData"
    },
    {
      "name": "Timestamp Field",
      "value": "ModificationTimestamp",
      "defaultValue": "DefTimestamp"
    }
  ]
}

Sample DD report that can be validated using the DD schema:

{
  "providerUoi": "M00000001",
  "endorsement": "data-dictionary",
  "version": "1.7",
  "config": [
    {
      "description": "Bearer Template - 0",
      "serviceRootUri": "abc.com",
      "recipientUoi": "T00000052",
      "providerUsi": "50024",
      "token": "token1"
    },
    {
      "description": "Bearer Template - 1",
      "serviceRootUri": "bbc.com",
      "recipientUoi": "T00000099",
      "providerUsi": "50024",
      "token": "token2"
    }
  ]
}

Usage with AJV

AJV can run on both the browser and the server. We can use it as follows to validate the config:

// ESM/TypeScript import
import Ajv from "ajv"
// or Node.js require:
const Ajv = require("ajv")

const ajv = new Ajv()

const schema = "<DD or WebAPI schema>";

const data = "<DD or WebAPI config to be tested against the schema>";

const validate = ajv.compile(schema)
const valid = validate(data)
if (!valid) console.log(validate.errors)
else console.log("The data is valid against the given schema")

Notes

I think the WebAPI needs some more validation logic for default values but it isn't clear to me atm. Once that is done, this PR will be ready.

cc: @darnjo, @eswar-tallapudi

@mohit-s96 mohit-s96 changed the title #1: added initial schemas for DD and WebAPI configs #1: schemas for DD and WebAPI configs Feb 16, 2023
@mohit-s96 mohit-s96 self-assigned this Feb 16, 2023
@eswar-tallapudi
Copy link

The ddSchema config to validate the uploaded file from file uploader (Cert UI) works fine. We may want to finalise the webAPISchema config to finish the schema validation for webApi and DD.

@eswar-tallapudi
Copy link

@mohit-s96 We don't need "description": "Bearer Template - 1", on the data-dictionary schema anymore. Can you please update it?

cc: @darnjo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create DD and Web API Config JSON Schema
2 participants