Coder Social home page Coder Social logo

compare-gh-webhook-to-schema-function's People

Contributors

g-rath avatar github-actions[bot] avatar renovate[bot] avatar wolfy1339 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

gr2m wolfy1339

compare-gh-webhook-to-schema-function's Issues

Schemas are duplicated in the generated types

Whenever a schema has

"type": [
    "object",
    "null"
  ],

it duplicates the schema, by using the intersection type and wrapping it in parenthesis and appending | null, insteaf of just appending | null

Example: (common/installation)

{
  "$schema": "http://json-schema.org/draft-07/schema",
  "$id": "common/installation.schema.json",
  "type": [
    "object",
    "null"
  ],
  "required": [
    "id",
    "node_id"
  ],
  "properties": {
    "id": {
      "type": "integer"
    },
    "node_id": {
      "type": "string"
    }
  },
  "additionalProperties": false,
  "title": "Installation"
}

Will turn into

export type Installation = {
  id: number;
  node_id: string;
} & ({
  id: number;
  node_id: string;
} | null);

Don't push the same error, for the same property multiple times

{
  "summary": "oh dear, there were errors :/",
  "errors": [
    {
      "keyword": "enum",
      "dataPath": "/action",
      "schemaPath": "#/properties/action/enum",
      "params": {
        "allowedValues": [
          "assigned"
        ]
      },
      "message": "should be equal to one of the allowed values"
    },
    {
      "keyword": "enum",
      "dataPath": "/action",
      "schemaPath": "#/properties/action/enum",
      "params": {
        "allowedValues": [
          "closed"
        ]
      },
      "message": "should be equal to one of the allowed values"
    },
    {
      "keyword": "enum",
      "dataPath": "/action",
      "schemaPath": "#/properties/action/enum",
      "params": {
        "allowedValues": [
          "edited"
        ]
      },
      "message": "should be equal to one of the allowed values"
    },
    {
      "keyword": "enum",
      "dataPath": "/action",
      "schemaPath": "#/properties/action/enum",
      "params": {
        "allowedValues": [
          "labeled"
        ]
      },
      "message": "should be equal to one of the allowed values"
    },
    {
      "keyword": "enum",
      "dataPath": "/action",
      "schemaPath": "#/properties/action/enum",
      "params": {
        "allowedValues": [
          "locked"
        ]
      },
      "message": "should be equal to one of the allowed values"
    },
    {
      "keyword": "enum",
      "dataPath": "/action",
      "schemaPath": "#/properties/action/enum",
      "params": {
        "allowedValues": [
          "opened"
        ]
      },
      "message": "should be equal to one of the allowed values"
    },
    {
      "keyword": "enum",
      "dataPath": "/action",
      "schemaPath": "#/properties/action/enum",
      "params": {
        "allowedValues": [
          "ready_for_review"
        ]
      },
      "message": "should be equal to one of the allowed values"
    },
    {
      "keyword": "additionalProperties",
      "dataPath": "/pull_request",
      "schemaPath": "#/properties/pull_request/additionalProperties",
      "params": {
        "additionalProperty": "active_lock_reason"
      },
      "message": "should NOT have additional properties"
    },
    {
      "keyword": "enum",
      "dataPath": "/action",
      "schemaPath": "#/properties/action/enum",
      "params": {
        "allowedValues": [
          "review_request_removed"
        ]
      },
      "message": "should be equal to one of the allowed values"
    },
    {
      "keyword": "enum",
      "dataPath": "/action",
      "schemaPath": "#/properties/action/enum",
      "params": {
        "allowedValues": [
          "review_requested"
        ]
      },
      "message": "should be equal to one of the allowed values"
    },
    {
      "keyword": "enum",
      "dataPath": "/action",
      "schemaPath": "#/properties/action/enum",
      "params": {
        "allowedValues": [
          "synchronize"
        ]
      },
      "message": "should be equal to one of the allowed values"
    },
    {
      "keyword": "enum",
      "dataPath": "/action",
      "schemaPath": "#/properties/action/enum",
      "params": {
        "allowedValues": [
          "unassigned"
        ]
      },
      "message": "should be equal to one of the allowed values"
    },
    {
      "keyword": "enum",
      "dataPath": "/action",
      "schemaPath": "#/properties/action/enum",
      "params": {
        "allowedValues": [
          "unlabeled"
        ]
      },
      "message": "should be equal to one of the allowed values"
    },
    {
      "keyword": "enum",
      "dataPath": "/action",
      "schemaPath": "#/properties/action/enum",
      "params": {
        "allowedValues": [
          "unlocked"
        ]
      },
      "message": "should be equal to one of the allowed values"
    },
    {
      "keyword": "oneOf",
      "dataPath": "",
      "schemaPath": "#/oneOf",
      "params": {
        "passingSchemas": null
      },
      "message": "should match exactly one schema in oneOf"
    }
  ]
}

Instead of listing all possibilities in multiple errors for the action property, list them all in one, since allowedValues is an array

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.