Adding Metadata to APIs

Cette page n'est pas encore disponible en français, sa traduction est en cours.
Si vous avez des questions ou des retours sur notre projet de traduction actuel, n'hésitez pas à nous contacter.

Overview

You can add metadata to APIs through the Datadog UI or API, or use automated pipelines through the GitHub integration or Terraform.

Metadata structure and supported versions

API Catalog supports OpenAPI 2 and 3 as the format for defining APIs.

Datadog supports custom OpenAPI fields to help manage metadata:

  • API owner: Add the following to the top level of the OpenAPI file:
    x-datadog:
     teamHandle: dd-team
    

Example OpenAPI file:

openapi: 3.0.2
info:
 title: API Name
 description: API Description
 version: 1.0.0
x-datadog:
 teamHandle: dd-team
paths:
 /api/v2/customers/{id}:
   get:
     summary: get customer information
     operationId: getCustomerInfo
     tags:
       - public
       - important
     parameters:
       - in: path
         name: id
     responses:
       '200':
         description: Successful operation
         content:
           application/vnd.api+json:
             schema:
               type: object
               properties:
                 data:
                   type: array
                   description: Contains all customer information
       '400':
         description: Invalid arguments
       '401':
         description: Unauthorized operation
       '500':
         description: An internal server error

Automations for adding metadata

Add API metadata from a GitHub repository

Use the Datadog GitHub integration to import API definitions and keep them updated. After connecting, the API automatically updates whenever the file content changes in the repository.

To import an OpenAPI or Swagger file using the GitHub integration:

  1. Set up the Datadog GitHub integration.
  2. Navigate to the API Catalog in Datadog.
  3. Click on the Manage tab, and select Add API.
  4. Select GitHub.
  5. Choose the repository and the file you want to register.
  6. Select Create.
API Catalog modal showing how to create a new API from GitHub

Further reading

Documentation, liens et articles supplémentaires utiles: