👍🎉 Welcome! And thanks for taking the time to contribute! 🎉👍
Important note: we are designing in public (this repository is open for the world to see and contribute if they want). Do not post any confidential information in this repository (whether as a commit or a comment on a PR). See Rebilly security policies for more information about data classification.
Rebilly follows a design-first approach to APIs.
- Use OpenAPI 3.0 to describe APIs according to below.
- Use GitHub flow (create a branch and open a pull request for any change).
- Check your work with Redocly CLI which runs
lint
andbundle
commands controlled through theredocly.yaml
configuration file when a pull request is opened (you will see the green checks or red x marks). - In terms of sequence, merge the API definitions before merging and releasing software to production.
To get started:
- Set up your environment.
- Read the remainder of this page to understand how we design APIs and write API definitions.
For guidance on how to write API descriptions when contributing to Rebilly APIs, see Writing style.
Rebilly uses the following lint rules:
- The Redocly
recommended
configuration denoted as "recommended" - Additional available Redocly rules denoted as "Redocly additional rules"
- Custom rules denoted as "custom rules".
- no-unresolved-refs (recommended)
- no-unused-components (Redocly additional rules)
- security-defined (recommended)
- spec (recommended)
- spec-components-invalid-map-name (recommended)
- operation-2xx-response (Redocly additional rules)
- operation-4xx-response (turned off due to webhooks)
- operation-4xx-problem-details-rfc7807 (not used)
- operation-description (use custom rules instead)
- operation-operationId (Redocly additional rules)
- operation-operationId-unique (recommended)
- operation-operationId-url-safe (recommended)
- operation-summary (recommended)
- rule/x-sdk-operation-name (custom rules)
- rule/operation-id-delete (custom rules)
- rule/operation-id-get (custom rules)
- rule/operation-id-patch (custom rules)
- rule/operation-id-post (custom rules)
- rule/operation-id-put (custom rules)
- rule/no-x-code-samples (custom rules)
- rule/no-x-internal (custom rules)
- boolean-parameter-prefixes (Redocly additional rules)
- no-invalid-parameter-examples (Redocly additional rules)
- operation-parameters-unique (recommended)
- parameter-description (Redocly additional rules)
- path-declaration-must-exist (recommended)
- path-not-include-query (recommended)
- path-parameters-defined (recommended)
- rule/params-must-include-examples (custom rules)
- no-ambiguous-paths (Redocly additional rules)
- no-http-verbs-in-paths (Redocly additional rules) (1 exception)
- no-identical-paths (recommended)
- no-path-trailing-slash (recommended)
- path-excludes-patterns
- path-segment-plural (Redocly additional rules)
- paths-kebab-case (Redocly additional rules)
- rule/path-must-be-ref-file (custom rules)
- no-enum-type-mismatch (recommended)
- no-example-value-and-externalValue (recommended)
- no-invalid-media-type-examples (Redocly additional rules)
- no-invalid-schema-examples (Redocly additional rules)
- request-mime-type (Redocly additional rules)
- response-mime-type (Redocly additional rules)
- response-contains-header (Redocly additional rules)
- response-contains-property
- scalar-property-missing-example
- rule/headers-include-example (custom rules)
- rule/schema-properties-both-created-time-and-updated-time (custom rules)
- rule/put-200-and-201 (custom rules) (this has some exceptions)
- rule/schema-properties-camelCase (custom rules)
- rule/embedded-is-object (custom rules)
- no-empty-servers (recommended)
- no-server-example.com (Redocly additional rules)
- no-server-trailing-slash (recommended)
- no-server-variables-empty-enum (recommended)
- no-undefined-server-variable (recommended)
- operation-singular-tag (Redocly additional rules)
- operation-tag-defined (Redocly additional rules)
- tag-description
- tags-alphabetical
- custom-rules/no-unused-tags (custom rules)
- rule/operation-summary (custom rules)
- rule/tag-description (custom rules)
- rule/info-description (custom rules)
- rule/description-capitalization (custom rules)
- rule/description-punctuation (custom rules)
- rule/no-anthropomorphic-possessives (custom rules)
- rule/no-past-future (custom rules)
- rule/no-description-start-with-the-a-an (custom rules)
Set up lint rules to enforce any design rules to keep this list to a minimum (and remove from this list as rules are enabled to automate these checks).
- The schema filename should be singular and start with an uppercase letter (
Customer.yaml
). - Always use US-English.
- Define all properties explicitly (whenever possible).
- List required properties.
- Mark properties read or write only when appropriate.
- Re-use schemas by reference objects (
$ref
). Some commonly used include:ResourceId
CreatedTime
UpdatedTime
- Most APIs have a
_links
property (with at least "self" link). - If a resource has nested objects, consider separating them with the reference objects (
$ref
) if they have potential for reuse. - You may organize schemas into sub-folders when appropriate.
- Follow path conventions
- Use appropriate HTTP methods.
- POST to insert a new resource.
- PUT to create with specified ID or replace existing Resource (must return 200 for updated and 201 for created).
- GET to get a resource or a collection.
- DELETE to delete a resource.
- Response must contain http header
Location
of the newly created resource; if the status is 201, theLocation
header must exist.
- Add
"#/parameters/collectionLimit"
and"#/parameters/collectionOffset"
to Resource collection, if pagination is needed. - Add
"#/parameters/collectionFields"
to Resource collection to allow return only specified fields. - Add
"#/parameters/collectionExpand"
to Resource collection if Resource contains embedded resources. - Add
"#/parameters/collectionQuery"
to Resource collection if Resource support search by ‘?q=’ param. - Add
"#/parameters/collectionFilter"
to Resource collection if Resource support search by ‘?filter=’ param. - Add
"#/parameters/collectionCriteria"
to Resource collection if Resource support search by ‘?criteria=’ param. - Add
"#/parameters/collectionSort"
to Resource collection if Resource support sorting.- Define all sortable properties.