Profile
Back to NewsBack
GitHub Trending 7 min
Reader Mode
vtex/openapi-schemas: OpenAPI 3.0 JSON schemas. Files are automatically synced to the VTEX Developer Portal.

vtex/openapi-schemas: OpenAPI 3.0 JSON schemas. Files are automatically synced to the VTEX Developer Portal.

openapi-schemas

This documentation comprises VTEX's public APIs as OpenAPI 3.0 JSON schemas. Files are automatically synced with VTEX's Developer Portal API Reference page and can be imported to Postman following these instructions.

Table of Contents

- Servers - Authentication - Security schemes - Security requirement - Spectral Linter - Postman Collection Converter - OpenAPI Preview

External contributions

Please check our Contributing Guide for more information about how to contribute with this repository.

Code of Conduct

Please read our Code of Conduct before contributing.

API Slug Mapping

The OpenAPI schema files in this repository follow a naming convention that integrates with the Developer Portal's centralized API slug mapping system. This ensures consistent URLs and naming across documentation.

Read the Centralized API Slug Mapping documentation to learn how API names are mapped to URL slugs and how to follow the naming conventions when adding new API schemas.

VTEX APIs

Requisites

Before contributing to this repository, read the following requisites.

Servers

OpenAPI describes the full endpoint for accessing the API as {server URL} + {endpoint path} + {path parameters}.

Example: an endpoint with /api/getResults as the path, https://example.com as the URL in the server object and no parameters will send requests to the https://example.com/api/getResults URL.

Example - servers object:

"servers": [
    {
        "url": "https://{accountName}.{environment}.com.br",
        "description": "VTEX server URL.",
        "variables": {
            "accountName": {
                "description": "Name of the VTEX account. Used as part of the URL.",
                "default": "apiexamples"
            },
            "environment": {
                "description": "Environment to use. Used as part of the URL.",
                "enum": [
                    "vtexcommercestable"
                ],
                "default": "vtexcommercestable"
            }
        }
    }
],

The servers key contains an array of objects.

Authentication

Security schemes

Security schemes describe autentication types that are available in the API. You can check the all the available options in the Security Scheme Specification.

They should be added inside the components object.

The security schemes we use are:

"securitySchemes": {
    "appKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-VTEX-API-AppKey",
        "description": "Unique identifier of the API key."
    },
    "appToken": {
        "type": "apiKey",
        "in": "header",
        "name": "X-VTEX-API-AppToken",
        "description": "Secret token of the API key."
    },
    "VtexIdclientAutCookie": {
        "type": "apiKey",
        "in": "header",
        "name": "VtexIdclientAutCookie",
        "description": "User token, valid for 24 hours."
    }
}

Security requirement

If defined inside the Open API schema, the security object will define the required security schemes for all endpoints. This specifies that requests should have the X-VTEX-API-AppKey and X-VTEX-API-AppToken pair or VtexIdClientAutCookie as part of the request header.

If defined inside an endpoint object, the security object will define the security scheme for that specific endpoint.

The security object we use at VTEX is:

"security": [
        {
            "appKey": [],
            "appToken": []
        },
        {
            "VtexIdclientAutCookie": []
        }
    ]

AI-Powered Documentation

⚠️ These tools are available exclusively for VTEX technical writers working in Cursor IDE. External contributors should follow the Contributing Guide for manual contributions.

This repository includes Cursor IDE commands for automated OpenAPI generation and maintenance:

Available Commands

  • /generate-openapi - Generate OpenAPI schemas from source code
  • /review-openapi - Review and update existing OpenAPI schemas
  • /rate-openapi - Evaluate schema quality with automated scoring
  • /analyze-pr-changes - Analyze PR changes for API impacts
  • /spectral - Run Spectral linting and validate schemas

Documentation

Complete guides are available in the docs/openapi-gen/ directory:

Learn more in the OpenAPI Generation Introduction.

GitHub Actions

This repository uses GitHub Actions for automated workflows that help maintain code quality and generate necessary artifacts. Below are the details of each action:

Spectral Linter

Source File: .github/workflows/linter.yml

Summary: This action runs Spectral to lint OpenAPI specification files when pull requests are created or updated. It helps maintain consistency and quality in API specifications.

Trigger Conditions:

  • On pull request creation or update
Dependencies:
  • actions/checkout@v4: Checks out the repository code
  • mshick/add-pr-comment@v2: Adds automated comments to pull requests
  • stoplightio/[email protected]: Runs the Spectral linter on OpenAPI files

Postman Collection Converter

Source File: .github/workflows/portman.yml

Summary: This action automatically converts OpenAPI specifications to Postman Collections when changes are made to JSON files in pull requests targeting the master branch.

Trigger Conditions:

  • On pull request to master branch
Dependencies:
  • actions/checkout@v2: Checks out the repository code
  • actions/setup-node@v2: Sets up Node.js environment
  • @apideck/portman: NPM package for converting OpenAPI specs to Postman collections
  • ad-m/[email protected]: Pushes generated files back to the repository

OpenAPI Preview

Source File: .github/workflows/openapi-preview.yml

Summary: This action automatically posts a preview comment on pull requests with direct links to visualize changed OpenAPI specs. The comment is created on PR open and updated on each new push.

Trigger Conditions:

  • On pull request creation or update targeting any *.json file
Dependencies:
  • actions/checkout@v4: Checks out the repository code
  • actions/github-script@v7: Posts and updates PR comments with preview links

Chat with me