Apidog Documentation

website·Indexed 34 days ago

https://af46vr0mkz.apidog.io

A platform for API designers and back-end developers to specify APIs via OpenAPI specifications, generate code, run requests, and debug using variables and pre-processors. The documentation includes guides on team collaboration throughout the API lifecycle and sample API specifications for pet stores, user management, and payment modules.

Tokens
12K
Snippets
66
Records
103
Agent score
49%

What's inside Apidog

  1. Define a Cat object using OpenAPI Specification

    The Cat schema is defined as an object containing detailed information about a cat. It requires several fields including name, age, weight, and behavioral/environmental traits. The petType property defaults to 'cat'.
    Cat:
      type: object
      properties:
        name:
          type: string
        age:
          type: integer
        weight:
          type: number
        petType:
          type: string
          default: cat
        isVaccinated:
          type: boolean
        isIndoor:
          type: boolean
        litterBoxType:
          type: string
        scratchingPostHeight:
          type: integer
        favoriteSleepingSpot:
          type: string
      required:
        - name
        - age
        - weight
        - petType
        - isVaccinated
        - isIndoor
        - litterBoxType
        - scratchingPostHeight
        - favoriteSleepingSpot
  2. Retrieve pet information via the /pets endpoint

    Use the GET /pets endpoint to retrieve information about pets. A successful response (HTTP 200) returns a Pet object in JSON format. The Pet object is polymorphic and can be either a Dog or a Cat, distinguished by the petType property.
    curl -X GET "https://<api-host>/pets"
  3. Use Pre Processors to manipulate requests

    Pre Processors are JavaScript operations executed before a request is sent. They can be used to modify request URLs, headers, or variables, perform data transformation, or make prerequisite requests. Apidog supports the Postman SDK for accessing request/response objects and variables. Available pre-processor types include Custom Scripts, Public Scripts, Database Operations, and Wait.
    // Example: Increment an environment variable named 'Userid' before sending
    let Userid = parseInt(pm.environment.get("Userid"));
    Userid = Userid + 1;
    console.log(Userid);
    pm.environment.set("Userid", Userid);
  4. Implement GitHub OAuth 2.0 Authorization Code Flow

    To authenticate users via GitHub OAuth 2.0 using the Authorization Code flow, use the following endpoints and configuration. The flow requires the client to request an authorization code from the user and then exchange that code for an access token.
    # OAuth 2.0 Authorization Code Flow Configuration
    authorizationUrl: https://github.com/login/oauth/authorize
    tokenUrl: https://github.com/login/oauth/access_token
    
    # Common Scopes
    - read:user
    - user:email
    
    # Token Request Requirement
    # The token request should include the following header:
    Accept: application/json
  5. Publish and share API documentation

    Apidog can generate public-facing API documentation from designed APIs, including interactive 'Try it out' functionality and code generation.

    Steps to publish:

    1. Go to the Share module and create a +New share.
    2. Select the environment that should be active for the documentation readers.
    3. Open the shared link in a browser to view the generated docs.

    Key features of shared docs:

    • Code Samples: Generates request code in multiple languages.
    • Response Code Generation: Generates data structure code for responses in various languages.
    • Customization: Supports custom domains, top navigation, catalog styles, and content footers.
  6. Verify API response consistency in Apidog

    Apidog automatically verifies if the actual API response matches the defined API specification. It detects issues such as incorrect data types (e.g., a string returned when an integer was expected), undefined enumerated values, and missing required fields. Users can save these specific requests as 'API Cases' (children of the API) for later use in the testing module.
  7. Create and run automated API test scenarios

    Apidog allows grouping multiple API cases into a single test scenario to run them sequentially and generate a test report.

    Steps to create a test scenario:

    1. Navigate to the Testing module and create a New Test Case.
    2. Inside the case, use Add Step and select Import from API Cases.
    3. Select the desired API cases to import.
    4. Click Run to execute the sequence.
    5. Use the More option in the report to analyze failed APIs by comparing responses against assertions.
  8. Collaborate on the API development lifecycle with Apidog

    Apidog streamlines the API lifecycle by acting as a single source of truth for designers, developers, and QA engineers. The workflow typically follows these stages:

    1. Specification: API designers or back-end developers define the API specifications.
    2. Collaboration: The team reviews and improves documentation to ensure consistency across use cases.
    3. Front-end Development: Front-end developers use automatically generated mock data based on the specifications to begin development without manual mock rules.
    4. Back-end Development & Debugging: Back-end developers use defined API use cases to debug. If the API changes during this process, the documentation is automatically updated.
    5. Verification: Successful debug sessions can be saved as API use cases for QA engineers to test.
    6. Integration Testing: QA engineers use test cases and test collections to perform multi-API integration testing.
    7. Deployment: Once development is complete, Apidog generates public-facing API documentation for external teams.
  9. Generate and customize API Mock data

    Apidog provides 'Smart Mock' capabilities that automatically generate dynamic JSON data based on API specifications and node names (e.g., 'email' or 'lastName').

    Customization options include:

    • Manual Mock Values: Define specific values for nodes in the Edit tab.
    • Faker.js: Use Faker.js grammar for dynamic data generation.
    • Fixed Responses: Change 'Default Mock Type' to 'Response Example First' in Settings > Feature Settings > Mock Settings to use the API response example as the fixed mock response.
  10. Import APIs from OpenAPI specifications

    Apidog allows importing APIs defined in OpenAPI or other formats (such as Apidog, HAR, JSON, or YAML files) to enable debugging, testing, and mocking.

    Steps to import via URL:

    1. Click Import within an Apidog project.
    2. Select URL Import.
    3. Paste the OpenAPI specification URL and click Submit.
    4. Click Confirm to complete the import.
    https://petstore.swagger.io/v2/swagger.json
  11. Implement data-driven testing with external datasets

    When API cases use variables, you can perform data-driven testing by providing a data table or importing external files.

    Steps:

    1. Enable the Test Data switch and click Manage Data.
    2. Define variables and datasets. Data can be entered manually or imported via CSV or JSON files.
    3. Save and run the test; Apidog will iterate through the test case using the values provided in the dataset.
  12. Use dynamic values in API requests

    Dynamic variables allow the automatic generation of parameter values for each request, which is useful for unique identifiers or random data.

    Steps:

    1. In the API case Detail view, click the magic wand (🪄) button to open the Dynamic Value dialog.
    2. Select a Datatype (e.g., number) and click Insert.
    3. The dynamic value is processed at runtime. The actual value sent can be verified in the Actual Request log.
    4. Dynamic values can be inserted into request bodies in both JSON and XML formats.