| name | openapi-foundations |
| description | OpenAPI core rules 1-10 covering servers, naming, parameters, and basic patterns |
API Specification - Core Rules (Rules 1-10)
🚨 CRITICAL RULES - Immediate Task Failure if Violated
These are the foundational rules that EVERY agent working with API specifications must know.
Rule 1: No Root Level Servers or Security
servers:
- url: https://api.example.com
security:
- bearerAuth: []
openapi: 3.0.0
info:
title: Service API
Rationale: Module determines these dynamically from connection profile.
Rule 2: Resource Naming Consistency
- Choose ONE term for each resource type
- Use it EVERYWHERE consistently throughout the spec
/users
/users/{userId}
/users/{userId}/profile
/users
/user/{id}
/users/{userId}/userProfile
IMPORTANT: Use meaningful, standard resource names regardless of vendor API naming.
/organizations/{organizationId}/users
/organizations/{organizationId}/groups/{groupId}/members
/orgs/{orgId}/users
/o/{oid}/u/{uid}
URL Pattern Standard - Parent Context Rule:
Use the appropriate path pattern based on whether the resource needs a parent context:
/accessToken
/profile
/settings
/organizations/{organizationId}/users
/users/{userId}/repositories/{repositoryId}
/projects/{projectId}/tasks/{taskId}
/auth/accessToken
/users/profile
Decision Rule:
- Use
/resource: When the resource is standalone OR operates on "current" context (current user, current token, etc.)
- Use
/parent/{parentId}/resource: When the resource exists within a parent that must be identified by an ID parameter
Pattern: /resources/{resourceId}/subResources/{subResourceId} format with meaningful, descriptive names. The vendor API may use different patterns - we normalize to our standard.
Rule 3: Complete Operation Coverage
- ALL operations from requirements MUST be implemented as API endpoints
- NO operations can be skipped
- If an operation cannot be implemented, STOP and report
Rule 4: Parameter Reuse via Components
If a parameter appears in 2+ operations → MUST go in components/parameters
components:
parameters:
limitParam:
name: limit
in: query
schema:
type: integer
paths:
/users:
get:
parameters:
- $ref: '#/components/parameters/limitParam'
/groups:
get:
parameters:
- $ref: '#/components/parameters/limitParam'
Rule 5: Property Naming - camelCase ONLY
NO EXCEPTIONS - Even if external API uses snake_case
properties:
userName:
type: string
createdAt:
type: string
avatarUrl:
type: string
properties:
user_name:
type: string
created_at:
type: string
Critical: Convert ALL external API snake_case properties to camelCase in schemas.
Rule 6: Sorting Parameters Standard Names
NEVER use sortBy, sortDir, sort, or variations - ALWAYS use:
parameters:
- name: orderBy
schema:
type: string
- name: orderDir
schema:
type: string
enum: [asc, desc]
parameters:
- name: sortBy
- name: sortDir
- name: sort
Rule 7: Path Parameters - Descriptive Names
Path parameters MUST indicate resource type
/resources/{resourceId}
/items/{itemId}/subitems/{subitemId}
/users/{userId}/repositories/{repositoryId}
/resources/{id}
/items/{itemId}/subitems/{id}
Rule 8: Resource Identifier Priority
When choosing the primary identifier:
id (if exists and unique)
name (if unique)
- Other unique field (handle, key, etc.)
Always prefer id when available for operations.
Rule 9: Parameters - No Connection Context
Operations MUST NOT include parameters available from ConnectionProfile or ConnectionState
parameters:
- name: apiKey
in: header
- name: token
in: header
- name: baseUrl
in: query
/organizations/{organizationId}/resources/{resourceId}:
get:
parameters:
- name: organizationId
in: path
- name: resourceId
in: path
- name: includeDetails
in: query
WHY: Connection context (apiKey, token, baseUrl) is established during connect() and managed by the client. Operations define business parameters AND scope parameters (organizationId, workspaceId, projectId, etc.) because connection must not limit operational scope.
Rule 10: Tags - Lowercase Singular Nouns Only
tags:
- user
- group
- account
- access
tags:
- User
- Users
- Access
Quick Validation Checklist
Before proceeding with API spec work, verify:
These 10 core rules apply to ALL API specification work. Violation of any rule = immediate task failure.