How to Set an Enumeration for a Field (e.g. string, array, etc.) in Apidog

Set Apidog enumerations for strings, arrays, and more with this guide. Learn to use AI, JSON Schema, and reusable models for clear, error-free API documentation and testing.

Ashley Goolam

Ashley Goolam

13 August 2025

How to Set an Enumeration for a Field (e.g. string, array, etc.) in Apidog

Hey there! If you’re diving into API design with Apidog and want to make your interfaces crystal clear, setting up enumerations (or enums) is a must. Enums let you define a fixed set of values for a field—like “active,” “frozen,” or “deleted” for a user status—ensuring developers only pick from those options. This prevents pesky errors and keeps your API documentation sharp. In this conversational guide, we’ll explore how to set enumerations for strings, arrays, and more in Apidog, using its intuitive UI and AI-powered features. Whether you’re a beginner or a seasoned dev, you’ll be setting Apidog enumerations like a pro in no time. Let’s get started!

💡
Want a great API Testing tool that generates beautiful API Documentation?

Want an integrated, All-in-One platform for your Developer Team to work together with maximum productivity?

Apidog delivers all your demands, and replaces Postman at a much more affordable price!
button

Why Use Enumerations in Apidog?

Enumerations are like guardrails for your API fields. Imagine a “user status” field where only “active,” “frozen,” or “deleted” are valid. Without an enum, developers might accidentally pass “inactive” or “banned,” causing your API to choke. By setting Apidog enumerations, you explicitly list allowed values, making your documentation clear and reducing errors. Plus, Apidog’s Mock data feature automatically respects these enums, generating test data that sticks to your rules. Whether it’s a string like “pending” or an array of specific permissions, enums streamline collaboration and keep your API robust.

Apidog, a powerful platform for API design, debugging, and testing, supports enums for various data types, including strings, integers, numbers, and arrays. You can even add descriptions to each value for extra clarity. Let’s dive into how to set them up, from basic strings to complex arrays, and explore how AI and reusable models can make your life easier.

Setting Up Basic Enumerations in Apidog

Let’s start with the simplest case: setting an enumeration for a string or number field, like a user status or order state. Here’s how to do it:

  1. Open the Interface Editor:
open the endpoint editor

2. Select the Data Type:

select a data type

3. Access Advanced Settings:

advanced settings

4. Add Enumeration Values:

enum values

5. Save and Check Documentation:

When debugging in Apidog, you can select these enum values directly from a dropdown, ensuring your test requests are valid. It’s a simple way to keep everyone on the same page!

Pro Tip: Use the Bulk Edit feature in the enum panel to paste multiple values at once, saving time for long lists.

Handling Array Enumerations in Apidog

Array enumerations are a bit trickier but super useful for fields like user permissions or coordinates. Apidog supports two types of array enums: restricting individual array elements or limiting the entire array to specific combinations. Let’s break it down.

Scenario 1: Restricting Array Element Values

Suppose you have a permissions field that’s an array of strings, where each string must be one of “read,” “write,” or “delete.” Valid arrays could be ["read"], ["write", "delete"], or ["read", "write", "delete"]. Here’s how to set it up:

  1. Set Field to Array Type:
set data type

2. Configure Sub-Element Type:

set sub-element data type

3. Add Enum Values:

set sub-element type

4. Optional: Enforce Uniqueness:

5. Save and Test:

Alternatively, you can edit the JSON Schema manually in the Advanced Settings tab:

{
  "type": "array",
  "items": {
    "type": "string",
    "enum": ["read", "write", "delete"]
  },
  "uniqueItems": true
}

This ensures every element in the array adheres to the enum.

Scenario 2: Restricting Entire Array Values

Sometimes, you want the entire array to be one of a few fixed combinations, like a coordinate field that can only be [0, 0] or [100, 100]. Here’s how:

  1. Set Field to Array Type:

2. Edit JSON Schema:

{
  "type": "array",
  "enum": [
    [0, 0],
    [100, 100]
  ]
}

3. Save and Verify:

This approach is less common but powerful for specific use cases, like predefined settings or fixed data structures.

Using AI to Simplify Enumeration Setup

Writing JSON Schema for complex enums, especially arrays, can feel like wrestling with syntax. Luckily, Apidog’s AI feature is here to save the day! It lets you describe your enum requirements in plain language, and it generates the correct configuration.

  1. Enable AI in Apidog:
enable ai features

2. Describe Your Needs:

Set an enum for the coordinate field to only allow [1, 2] or [3, 4].

3. Preview and Apply:

{
  "type": "array",
  "enum": [
    [1, 2],
    [3, 4]
  ]
}

4. Test It:

The AI is a lifesaver for complex schemas or when you’re unsure about JSON syntax. It’s faster than Googling and ensures accuracy.

Mock Data and Enumerations

One of Apidog’s coolest features is how it integrates enums with Mock data. Once you set an enum, Apidog’s Mock service automatically generates test data that respects your restrictions. For example:

This ensures your test data aligns with your API specs, making debugging and collaboration smoother. To enable Mock data, toggle the Mock option in the interface editor and preview the results.

mock data

Defining Reusable Enumeration Models

If the same enum appears across multiple endpoints—like user_status in user creation, update, and listing APIs—redefining it each time is a pain. Apidog lets you create reusable data models to keep things consistent.

  1. Create a Data Model:

2. Reference the Model:

3. Update Once, Sync Everywhere:

This approach saves time and ensures consistency across your project. It’s perfect for teams where multiple developers rely on the same enums.

Troubleshooting Common Enumeration Issues

Why Enumerations Make Apidog Shine

Apidog enumerations are a game-changer for API design. They clarify field restrictions, reduce errors, and enhance documentation readability. The AI feature simplifies complex setups, while reusable models ensure consistency. Mock data integration means your tests are always spec-compliant. Compared to tools like Postman, Apidog’s visual editor and AI make enum setup more intuitive, especially for arrays. Users praise Apidog for “making API docs foolproof,” and with enum support, it’s easy to see why.

Conclusion

Setting Apidog enumerations is a breeze, whether you’re restricting strings, numbers, or arrays. From the visual editor to AI-powered JSON Schema generation, Apidog makes your APIs robust and developer-friendly. Try creating a reusable enum model or using AI to speed things up, and share your tips in the comments. Let’s make API design smoother together!

💡
Want a great API Testing tool that generates beautiful API Documentation?

Want an integrated, All-in-One platform for your Developer Team to work together with maximum productivity?

Apidog delivers all your demands, and replaces Postman at a much more affordable price!
button

Explore more

How to Use Wave – An Open-source Terminal

How to Use Wave – An Open-source Terminal

Wave Terminal is an open-source terminal that blends classic command-line power with modern graphical tools, file previews, web browsing, and AI assistance. This guide shows you how to install, customize, and master Wave Terminal.

13 August 2025

How to Use BlueJ - A Free Java Development Environment for Beginners

How to Use BlueJ - A Free Java Development Environment for Beginners

BlueJ is a free Java development environment that makes learning object-oriented programming simple and interactive. This guide shows you how to install, use, and master BlueJ's visual tools.

13 August 2025

How to run Test Scenarios with Cloud Database Connection Configuration via CLI

How to run Test Scenarios with Cloud Database Connection Configuration via CLI

Learn how to run database-connected test scenarios via CLI using ApiDog's cloud configuration. Secure, efficient setup with local values & Vault variables.

11 August 2025

Practice API Design-first in Apidog

Discover an easier way to build and use APIs