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 schemas for clear, error-free API documentation and testing.

Ashley Goolam

Ashley Goolam

25 September 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!

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 schemas 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 endpoint Editor:
open the endpoint editor

2. Select the Data Type:

select a data type

3. Access Advanced Settings:

advanced settings
  1. 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
  1. 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 Schemas

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

  1. Create a schema:

2. Reference the schema

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.

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. Let's make API design smoother together!

button

Explore more

How to Use Veo 3.1 API

How to Use Veo 3.1 API

Discover how to use the Veo 3.1 API for generating high-quality videos with audio and advanced controls.

16 October 2025

How to Use Claude Haiku 4.5 API

How to Use Claude Haiku 4.5 API

Discover how to integrate and utilize the Claude Haiku 4.5 API for efficient AI-driven applications. This guide covers setup, features, pricing, and advanced usage, including testing with Apidog.

16 October 2025

How Can You Master the GPT-5 Search API in 2025?

How Can You Master the GPT-5 Search API in 2025?

Unlock the potential of OpenAI's gpt-5-search-api-2025-10-14 and gpt-5-search-api with this step-by-step technical guide. Developers learn setup, implementation, parameters, and integration strategies for real-time web searches. Leverage Apidog for seamless API testing and optimization

15 October 2025

Practice API Design-first in Apidog

Discover an easier way to build and use APIs