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

Create JSON Schema for API Definition #26

Open
DeeJayTC opened this issue May 11, 2022 · 0 comments
Open

Create JSON Schema for API Definition #26

DeeJayTC opened this issue May 11, 2022 · 0 comments
Assignees
Labels

Comments

@DeeJayTC
Copy link
Owner

Is your feature request related to a problem? Please describe.
Create a JSON Schema to ease JSON based API development

Starting point:

{
  "$schema": "https://www.github.com/deejaytc/net-dynamic-api/apidefinition-schema.json",
  "$id": "https://www.github.com/deejaytc/net-dynamic-api/apidefinition-schema.json",
  "type": "array",
  "default": [],
  "items": {
      "type": "object",
      "title": "API Definition for a single class",
      "required": [
          "name",
          "route",
          "idType",
          "Fields"
      ],
      "properties": {
          "name": {
              "type": "string",
              "title": "Name of the class",
              "examples": [
                  "Make",
                  "Car"
              ],
              "pattern": "^[a-zA-Z]+$"
          },
          "route": {
              "type": "string",
              "title": "Api route ie /students for the class",
              "examples": [
                  "/make",
                  "/cars"
              ]
          },
          "idType": {
              "type": "string",
              "title": "Type of primary key, allows string, int and guid",
              "examples": [
                  "int"
              ],
              "oneOf": [
                  {"enum": ["int", "string", "guid"]}
              ]
          },
          "Fields": {
              "type": "array",
              "title": "The Fields Schema",
              "items": {
                  "type": "object",
                  "title": "A Schema",
                  "required": [
                      "name",
                      "type"
                  ],
                  "properties": {
                      "name": {
                          "type": "string",
                          "title": "The name Schema",
                          "examples": [
                              "Name",
                              "Description",
                              "Year",
                              "Make",
                              "MakeId"
                          ]
                      },
                      "type": {
                          "type": "string",
                          "title": "The type Schema",
                          "description": "Any compilable type",
                          "examples": [
                              "String",
                              "int",
                              "virtual Make",
                              "List<Make>"
                          ]
                      }
                  },
                  "examples": [{
                      "name": "Name",
                      "type": "String"
                  },
                  {
                      "name": "Description",
                      "type": "String"
                  },
                  {
                      "name": "Year",
                      "type": "int"
                  },
                  {
                      "name": "Name",
                      "type": "String"
                  },
                  {
                      "name": "Description",
                      "type": "String"
                  },
                  {
                      "name": "Year",
                      "type": "int"
                  },
                  {
                      "name": "Make",
                      "type": "virtual Make"
                  },
                  {
                      "name": "MakeId",
                      "type": "int"
                  }]
              },
              "examples": [
                  [{
                      "name": "Name",
                      "type": "String"
                  },
                  {
                      "name": "Description",
                      "type": "String"
                  },
                  {
                      "name": "Year",
                      "type": "int"
                  }],
                  [{
                      "name": "Name",
                      "type": "String"
                  },
                  {
                      "name": "Description",
                      "type": "String"
                  },
                  {
                      "name": "Year",
                      "type": "int"
                  },
                  {
                      "name": "Make",
                      "type": "virtual Make"
                  },
                  {
                      "name": "MakeId",
                      "type": "int"
                  }]
              ]
          }
      },
      "examples": [{
          "name": "Make",
          "route": "/make",
          "idType": "int",
          "Fields": [{
              "name": "Name",
              "type": "String"
          },
          {
              "name": "Description",
              "type": "String"
          },
          {
              "name": "Year",
              "type": "int"
          }]
      },
      {
          "name": "Car",
          "route": "/cars",
          "idType": "int",
          "Fields": [{
              "name": "Name",
              "type": "String"
          },
          {
              "name": "Description",
              "type": "String"
          },
          {
              "name": "Year",
              "type": "int"
          },
          {
              "name": "Make",
              "type": "virtual Make"
          },
          {
              "name": "MakeId",
              "type": "int"
          }]
      }]
  },
  "examples": [
      [{
          "name": "Make",
          "route": "/make",
          "idType": "int",
          "Fields": [{
              "name": "Name",
              "type": "String"
          },
          {
              "name": "Description",
              "type": "String"
          },
          {
              "name": "Year",
              "type": "int"
          }]
      },
      {
          "name": "Car",
          "route": "/cars",
          "idType": "int",
          "Fields": [{
              "name": "Name",
              "type": "String"
          },
          {
              "name": "Description",
              "type": "String"
          },
          {
              "name": "Year",
              "type": "int"
          },
          {
              "name": "Make",
              "type": "virtual Make"
          },
          {
              "name": "MakeId",
              "type": "int"
          }]
      }]
  ]
}
@DeeJayTC DeeJayTC added the vnext label May 11, 2022
@DeeJayTC DeeJayTC self-assigned this May 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant