Coder Social home page Coder Social logo

Comments (3)

wolfy1339 avatar wolfy1339 commented on June 3, 2024

Here's a rough idea of how to make schemas

Creating a new schema

Schemas are manually created using example payloads for webhook events.

  • Create a new folder for the event in payload-schemas/api.github.com, if it doesn't already exist
  • Create a new empty JSON file named <action>.schema.json if the event has an action property, otherwise name it event.schema.json
  • Set the $schema property to "http://json-schema.org/draft-07/schema"
  • The $id property's value should be in the format <eventName>$action, where <eventName> is the name of the event, and action is the value of the action property of the webhook payload or simply event if there is no action property for the event
  • the title property's value should be in the format <eventName> <action> event, where <eventName> is the name of the event, and <action> is the value of the action property of the webhook payload. If there is no action, the it should simply be <eventName> event
  • type should be object
  • Add any required properties in an array in the required property
  • Define properties of the payload in the properties property as an object in that property, like so:
{
   "properties": {
      "myproperty": {
         "type": "int",
         "description": "My Property's description"
      }
   }
}
  • When a property is a string, or number and has a defined set of values it can be, add the values in an array in the enum property of the property's object
  • When a property can be of multiple types, use a oneOf for the decleration of that property, and declare each type in the oneOf
  • When a property can be not present:
    • if there is only one other type the property can be, change the type property to an array including the type, and the string null
    • if there are more than one other type, that the property can be, simply add it to the oneOf
  • Repeat until you reach the lowest level of the payload
  • Add "additionalProperties": false to each property of the payload, and to the root of the document as well

from webhooks.

gr2m avatar gr2m commented on June 3, 2024

This is great! Would you like to send a pull request for the contributing file?

from webhooks.

octokitbot avatar octokitbot commented on June 3, 2024

🎉 This issue has been resolved in version 6.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

from webhooks.

Related Issues (20)

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.