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 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!
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:
- Open the Interface Editor:
- In Apidog, navigate to your project and open the interface (endpoint) you’re working on. Find the field you want to restrict, like
user_status
in the request or response body.

2. Select the Data Type:
- In the field’s settings, choose the data type from the dropdown—typically
string
(e.g., for “active”),integer
, ornumber
. For example, selectstring
foruser_status
.

3. Access Advanced Settings:
- Click the Advanced Settings button next to the field type. This opens a panel where you can configure the enum.

4. Add Enumeration Values:
- In the Enumeration Values section, enter your allowed values, one per line. For
user_status
, you might add: active
(Description: “User is active and can log in”)frozen
(Description: “User account is temporarily suspended”)deleted
(Description: “User account is permanently removed”)- Optionally, add descriptions for each value to make the documentation clearer.

5. Save and Check Documentation:
- Save your changes. In the API documentation, Apidog will display these values as the only valid options for the field. Team members will see something like: “
user_status
: Must be one of [active, frozen, deleted].”
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:
- Set Field to Array Type:
- In the interface editor, set the field (e.g.,
permissions
) toarray
type.

2. Configure Sub-Element Type:
- Under the array settings, you’ll see a Sub-Element Type option. Choose
string
(or another type likeinteger
).

3. Add Enum Values:
- Click Advanced Settings for the sub-element. In the Enumeration Values section, add:
read
(Description: “Read-only access”)write
(Description: “Write access”)delete
(Description: “Delete access”)

4. Optional: Enforce Uniqueness:
- In the array’s advanced settings, enable All Elements Must Be Unique to prevent duplicates (e.g.,
["read", "read"]
becomes invalid).
5. Save and Test:
- Save, and the documentation will show the array’s elements are restricted to these values. Mock data will generate arrays like
["read", "write"]
, respecting the enum and uniqueness rules.
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:
- Set Field to Array Type:
- Choose
array
for the field (e.g.,coordinate
).
2. Edit JSON Schema:
- In Advanced Settings, switch to the JSON Schema editor and input:
{
"type": "array",
"enum": [
[0, 0],
[100, 100]
]
}
- This restricts the field to exactly these arrays—no other combinations like
[0, 100]
are allowed.
3. Save and Verify:
- Save, and the documentation will list
[0, 0]
and[100, 100]
as the only valid values. Mock data will randomly select one of these arrays.
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.
- Enable AI in Apidog:
- Go to Team Settings > AI Features and enable AI assistance. Check Apidog’s help docs for details.

2. Describe Your Needs:
- In the interface editor, open the AI chat panel and type something like:
Set an enum for thecoordinate
field to only allow[1, 2]
or[3, 4]
.
- Or for a string: “Restrict
status
topending
,paid
, orcompleted
.”
3. Preview and Apply:
- The AI generates the JSON Schema, like:
{
"type": "array",
"enum": [
[1, 2],
[3, 4]
]
}
- Review the output, then click Apply to add it to your field.
4. Test It:
- Check the documentation to ensure the enum is correct. Try debugging with the enum values in Apidog’s interface.
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:
- String Enum: If
status
is restricted to["active", "frozen", "deleted"]
, Mock data will randomly pick one of these values. - Array Enum with Unique Elements: For a
permissions
array with["read", "write", "delete"]
and uniqueness enabled, you might get["read", "write"]
but never["read", "read"]
. - Fixed Array Enum: A
coordinate
field with[[0, 0], [100, 100]]
will only return one of those exact arrays.
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.

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.
- Create a Data Model:
- Go to Data Models in your Apidog project.
- Click New Model, name it (e.g.,
UserStatusEnum
), and set the root node tostring
. - In Advanced Settings, add enum values like
active
,frozen
,deleted
with optional descriptions.
2. Reference the Model:
- In any interface, set the field’s type to Reference and select
UserStatusEnum
.
3. Update Once, Sync Everywhere:
- If you need to add a new status (e.g.,
suspended
), update theUserStatusEnum
model, and all referencing endpoints update automatically.
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
- Enum Not Showing in Docs? Save the interface and refresh the documentation page. Ensure the field is marked as Required if needed.
- Mock Data Ignoring Enums? Check that the enum values are correctly set in Advanced Settings or JSON Schema. Toggle the Mock option off and on.
- Array Enum Errors? For element-level enums, ensure the sub-element type is set correctly. For fixed arrays, verify the JSON Schema syntax.
- AI Not Generating Schema? Clarify your prompt (e.g., “Restrict to exact arrays”) and ensure AI is enabled in Team Settings.
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 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!