Skip to main content
bunjs-apidog Use when creating OpenAPI specs for Bun.js APIs, integrating with Apidog, documenting endpoints with schemas, or automating API specification imports via Apidog REST API. See bunjs for basics.
インストールへ移動 Skills Marketplace コミュニティが作成したAIスキルを発見・探索
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
直接コマンドでは確認用 Prompt が省略されます。実行前にソースを確認してください。
npx skills add https://github.com/MadAppGang/claude-code --skill bunjs-apidogコマンドは1行のまま表示されます。コピー前に横へスクロールして全体を確認してください。
ローカルで確認しますか?SkillsMP が現在取得できるファイルをダウンロードできます。
Zipをダウンロード ダウンロード中... SOC
name bunjs-apidog version 1.0.0 description Use when creating OpenAPI specs for Bun.js APIs, integrating with Apidog, documenting endpoints with schemas, or automating API specification imports via Apidog REST API. See bunjs for basics. keywords ["OpenAPI","Apidog","API documentation","Swagger","API specs","integration","API design"] plugin dev updated "2026-01-20T00:00:00.000Z"
Bun.js OpenAPI and Apidog Integration
Overview
This skill covers OpenAPI specification creation and Apidog integration for Bun.js TypeScript backend applications. Learn how to document APIs with OpenAPI 3.0, use Apidog-specific extensions, import specifications via REST API, and maintain synchronized API documentation.
When to use this skill:
Creating OpenAPI specifications for API documentation
Synchronizing API specs with Apidog projects
Importing endpoints and schemas to Apidog
Managing API documentation lifecycle
See also:
dev:bunjs - Core Bun patterns, HTTP servers, database access
dev:bunjs-architecture - Layered architecture, camelCase conventions
dev:bunjs-production - Production deployment patterns
Why Apidog Apidog is a comprehensive API development platform that combines:
API Design - Visual OpenAPI editor
API Documentation - Auto-generated, always up-to-date docs
API Testing - Built-in testing tools
API Mocking - Mock servers for frontend development
Team Collaboration - Shared workspace for teams
Environment Variables APIDOG_PROJECT_ID=your-project-id
APIDOG_API_TOKEN=your-api-token
APIDOG_PROJECT_ID : Open your Apidog project → Settings → Project ID
APIDOG_API_TOKEN : Apidog Account → Settings → API Tokens → Generate Token
OpenAPI Spec Creation
Basic Structure openapi: 3.0 .0
info:
title: My API
version: 1.0 .0
description: API for managing resources
servers:
- url: https://api.example.com/v1
description: Production server
- url: https://staging-api.example.com/v1
description: Staging server
- url: http://localhost:3000
description: Development server
components:
schemas:
securitySchemes:
bearerAuth:
type: http
scheme: bearer
bearerFormat: JWT
paths:
Field Naming: camelCase (CRITICAL) ALWAYS use camelCase for all JSON API field names in OpenAPI specs.
components:
schemas:
User:
type: object
required:
- userId
- emailAddress
properties:
userId:
type: string
format: uuid
emailAddress:
type: string
format: email
firstName:
type: string
lastName:
type: string
phoneNumber:
type: string
isActive:
type: boolean
createdAt:
type: string
format: date-time
updatedAt:
type: string
format: date-time
Native to JavaScript/JSON ecosystem
Industry standard (Google, Microsoft, AWS)
TypeScript friendly (1:1 mapping)
OpenAPI/Swagger convention
Auto-generated clients expect it
Schema Design Define reusable schemas in components.schemas:
components:
schemas:
User:
type: object
required:
- userId
- emailAddress
- firstName
- lastName
properties:
userId:
type: string
format: uuid
description: Unique user identifier
emailAddress:
type: string
format: email
description: User email address
firstName:
type: string
minLength: 2
maxLength: 100
lastName:
type: string
minLength: 2
maxLength: 100
phoneNumber:
type: string
pattern: '^\+?[1-9]\d{1,14}$'
role:
type: string
enum: [user , admin , moderator ]
default: user
isActive:
type: boolean
default: true
createdAt:
type: string
format: date-time
updatedAt:
type: string
format: date-time
CreateUserRequest:
type: object
required:
- emailAddress
- password
- firstName
- lastName
properties:
emailAddress:
type: string
format: email
password:
type: string
format: password
minLength: 8
firstName:
type: string
minLength: 2
lastName:
type: string
minLength: 2
phoneNumber:
type: string
role:
type: string
enum: [user , admin , moderator ]
UserListResponse:
type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/User'
pagination:
$ref: '#/components/schemas/Pagination'
Pagination:
type: object
properties:
page:
type: integer
minimum: 1
pageSize:
type: integer
minimum: 1
maximum: 100
total:
type: integer
totalPages:
type: integer
ErrorResponse:
type: object
properties:
statusCode:
type: integer
type:
type: string
message:
type: string
details:
type: array
items:
type: object
properties:
field:
type: string
message:
type: string
Endpoint Definitions Define endpoints in paths:
paths:
/users:
get:
summary: List users
description: Retrieve paginated list of users
operationId: listUsers
tags:
- Users
security:
- bearerAuth: []
x-apidog-folder: User Management/Users
x-apidog-status: released
x-apidog-maintainer: backend-team
parameters:
- name: page
in: query
schema:
type: integer
minimum: 1
default: 1
- name: pageSize
in: query
schema:
type: integer
minimum: 1
maximum: 100
default: 20
- name: sortBy
in: query
schema:
type: string
enum: [createdAt , firstName , emailAddress ]
- name: orderBy
in: query
schema:
type: string
enum: [asc , desc ]
default: desc
responses:
'200':
description: Successful response
content:
application/json:
schema:
$ref: '#/components/schemas/UserListResponse'
'401':
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
post:
summary: Create user
description: Create a new user account
operationId: createUser
tags:
- Users
x-apidog-folder: User Management/Users
x-apidog-status: released
x-apidog-maintainer: backend-team
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CreateUserRequest'
responses:
'201':
description: User created successfully
content:
application/json:
schema:
type: object
properties:
data:
$ref: '#/components/schemas/User'
'400':
description: Invalid request
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'409':
description: User already exists
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'422':
description: Validation failed
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/users/{userId}:
get:
summary: Get user
description: Retrieve a single user by ID
operationId: getUser
tags:
- Users
security:
- bearerAuth: []
x-apidog-folder: User Management/Users
x-apidog-status: released
parameters:
- name: userId
in: path
required: true
schema:
type: string
format: uuid
responses:
'200':
description: Successful response
content:
application/json:
schema:
type: object
properties:
data:
$ref: '#/components/schemas/User'
'404':
description: User not found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
Apidog-Specific Extensions
x-apidog-folder Organize endpoints in folders using / to separate levels:
paths:
/users:
post:
x-apidog-folder: User Management/Users
/users/{userId}/profile:
get:
x-apidog-folder: User Management/Users/Profile
/orders:
post:
x-apidog-folder: Order Management/Orders
Escaping special characters:
Use \/ for /
Use \\ for \
x-apidog-status Endpoint lifecycle status:
Status Description designingBeing designed pendingPending implementation developingIn development integratingIntegration phase testingBeing tested testedTesting complete releasedProduction release deprecatedMarked for deprecation exceptionHas issues obsoleteNo longer used to be deprecatedWill be deprecated
paths:
/users:
post:
x-apidog-status: released
/beta/feature:
post:
x-apidog-status: testing
/legacy/api:
get:
x-apidog-status: deprecated
x-apidog-maintainer Specify owner/maintainer (use Apidog username or nickname):
paths:
/users:
post:
x-apidog-maintainer: backend-team
/admin/settings:
put:
x-apidog-maintainer: john-doe
Importing to Apidog via REST API
Import Process Step 1: Prepare OpenAPI Spec
Create a complete OpenAPI 3.0 spec in JSON format:
cat > /tmp/api-spec.json << 'EOF'
{
"openapi" : "3.0.0" ,
"info" : { ... },
"paths" : { ... }
}
EOF
Step 2: Import via REST API
#!/bin/bash
APIDOG_PROJECT_ID="your-project-id"
APIDOG_API_TOKEN="your-api-token"
OPENAPI_SPEC=$(cat /tmp/api-spec.json | jq -c .)
curl -X POST "https://api.apidog.com/v1/projects/${APIDOG_PROJECT_ID} /import-openapi" \
-H "Authorization: Bearer ${APIDOG_API_TOKEN} " \
-H "X-Apidog-Api-Version: 2024-03-28" \
-H "Content-Type: application/json" \
-d "{
\"input\": \"${OPENAPI_SPEC} \",
\"options\": {
\"endpointOverwriteBehavior\": \"AUTO_MERGE\",
\"schemaOverwriteBehavior\": \"AUTO_MERGE\",
\"updateFolderOfChangedEndpoint\": false,
\"prependBasePath\": false
}
}"
Import Behavior Options Option Description AUTO_MERGEAutomatically merge changes (recommended) OVERWRITE_EXISTINGReplace existing endpoints/schemas completely KEEP_EXISTINGSkip changes, keep existing CREATE_NEWCreate new endpoints/schemas (duplicates existing)
Recommendation: Use AUTO_MERGE for intelligent merging without losing existing data.
API Response Format {
"data" : {
"counters" : {
"endpointCreated" : 3 ,
"endpointUpdated" : 2 ,
"endpointFailed" : 0 ,
"endpointIgnored" : 0 ,
"schemaCreated" : 5 ,
"schemaUpdated" : 1 ,
"schemaFailed" : 0 ,
"schemaIgnored" : 0 ,
"endpointFolderCreated" : 1 ,
"endpointFolderUpdated" : 0 ,
"schemaFolderCreated" : 0 ,
"schemaFolderUpdated" : 0
} ,
"errors" : [ ]
}
}
Error Handling Status Code Meaning 401 Token is invalid or expired 404 Project ID not found 422 OpenAPI spec validation failed
Check data.errors array for detailed error messages.
Workflow
1. Create OpenAPI Spec from Code Step 1: Analyze existing endpoints
find src/routes -name "*.ts" -type f
cat src/routes/user.routes.ts
Step 2: Extract schemas from Zod
import { z } from 'zod' ;
export const createUserSchema = z.object ({
emailAddress : z.string ().email (),
password : z.string ().min (8 ),
firstName : z.string (),
lastName : z.string ()
});
Step 3: Build OpenAPI spec
Map routes to OpenAPI paths, schemas to components, camelCase fields.
2. Validate Spec
npm install -g swagger-cli
swagger-cli validate api-spec.yaml
3. Import to Apidog
./scripts/import-to-apidog.sh
4. Verify in Apidog
Open Apidog project: https://app.apidog.com/project/{APIDOG_PROJECT_ID}
Check imported endpoints appear in correct folders
Verify schemas are properly structured
Test endpoints with Apidog's testing tools
Update descriptions and add examples
5. Set Endpoint Status Update x-apidog-status based on implementation progress:
designing → developing → testing → released
6. Share with Team Share Apidog project with team members for:
Frontend integration (use mock servers)
API testing
Documentation review
Automation Script scripts/import-to-apidog.sh:
#!/bin/bash
set -e
source .env
if [ -z "$APIDOG_PROJECT_ID " ] || [ -z "$APIDOG_API_TOKEN " ]; then
echo "Error: APIDOG_PROJECT_ID and APIDOG_API_TOKEN must be set"
exit 1
fi
SPEC_FILE="/tmp/api-spec-$(date +%Y%m%d-%H%M%S) .json"
echo "Generating OpenAPI spec..."
OPENAPI_SPEC=$(cat $SPEC_FILE | jq -c .)
echo "Importing to Apidog..."
RESPONSE=$(curl -s -X POST \
"https://api.apidog.com/v1/projects/${APIDOG_PROJECT_ID} /import-openapi" \
-H "Authorization: Bearer ${APIDOG_API_TOKEN} " \
-H "X-Apidog-Api-Version: 2024-03-28" \
-H "Content-Type: application/json" \
-d "{
\"input\": ${OPENAPI_SPEC} ,
\"options\": {
\"endpointOverwriteBehavior\": \"AUTO_MERGE\",
\"schemaOverwriteBehavior\": \"AUTO_MERGE\"
}
}" )
ENDPOINT_CREATED=$(echo $RESPONSE | jq -r '.data.counters.endpointCreated' )
ENDPOINT_UPDATED=$(echo $RESPONSE | jq -r '.data.counters.endpointUpdated' )
SCHEMA_CREATED=$(echo $RESPONSE | jq -r '.data.counters.schemaCreated' )
SCHEMA_UPDATED=$(echo $RESPONSE | jq -r '.data.counters.schemaUpdated' )
ERRORS=$(echo $RESPONSE | jq -r '.data.errors | length' )
echo ""
echo "✅ Import Complete!"
echo ""
echo "Endpoints:"
echo " Created: $ENDPOINT_CREATED "
echo " Updated: $ENDPOINT_UPDATED "
echo ""
echo "Schemas:"
echo " Created: $SCHEMA_CREATED "
echo " Updated: $SCHEMA_UPDATED "
echo ""
echo "Errors: $ERRORS "
echo ""
echo "🔗 View in Apidog: https://app.apidog.com/project/${APIDOG_PROJECT_ID} "
if [ "$ERRORS " != "0" ]; then
echo ""
echo "⚠️ Import had errors. Check response:"
echo $RESPONSE | jq '.data.errors'
exit 1
fi
Error Scenarios & Solutions
Missing Environment Variables Problem: APIDOG_PROJECT_ID or APIDOG_API_TOKEN not set
APIDOG_PROJECT_ID=your-project-id
APIDOG_API_TOKEN=your-api-token
Schema Conflicts Problem: New schema conflicts with existing schema
Use allOf to extend existing schemas
Or create with different name
Or use OVERWRITE_EXISTING behavior (carefully)
Import Failures Problem: Automated import fails
Check API token validity
Verify project ID
Validate OpenAPI spec syntax
Check data.errors in response for details
Invalid OpenAPI Spec Problem: Generated spec has validation errors
swagger-cli validate api-spec.yaml
Best Practices
1. Schema Reuse
paths:
/users/{userId}:
get:
responses:
'200':
content:
application/json:
schema:
type: object
properties:
data:
$ref: '#/components/schemas/User'
paths:
/users/{userId}:
get:
responses:
'200':
content:
application/json:
schema:
type: object
properties:
data:
type: object
properties:
userId: { type: string }
2. Comprehensive Descriptions
paths:
/users:
post:
summary: Create user
description: |
Creates a new user account with email verification.
The password must meet the following requirements:
- At least 8 characters
- Contains uppercase and lowercase letters
- Contains at least one number
- Contains at least one special character
Upon successful creation, a verification email is sent to the provided email address.
3. Response Examples responses:
'200':
description: Successful response
content:
application/json:
schema:
$ref: '#/components/schemas/User'
example:
data:
userId: "550e8400-e29b-41d4-a716-446655440000"
emailAddress: "john@example.com"
firstName: "John"
lastName: "Doe"
isActive: true
createdAt: "2025-01-06T12:00:00Z"
4. Security Schemes components:
securitySchemes:
bearerAuth:
type: http
scheme: bearer
bearerFormat: JWT
description: JWT access token obtained from /auth/login
security:
- bearerAuth: []
paths:
/public/health:
get:
security: []
5. Version Your API servers:
- url: https://api.example.com/v1
description: Version 1 (current)
- url: https://api.example.com/v2
description: Version 2 (beta)
OpenAPI and Apidog integration for Bun.js TypeScript backend. For core patterns, see dev:bunjs. For architecture, see dev:bunjs-architecture.