Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ class UserCreate(BaseModel):
"""Request body for creating a new user."""
name: str = Field(..., description="Full name of the user")
email: str = Field(..., description="Email address")
role: str = Field("member", description="User role")


class User(BaseModel):
"""Representation of a user returned by the API."""
id: int = Field(..., description="Unique user identifier")
name: str = Field(..., description="Full name of the user")
email: str = Field(..., description="Email address")
role: str = Field("member", description="User role")


class HealthResponse(BaseModel):
Expand Down Expand Up @@ -92,7 +94,7 @@ def get_user(user_id: int) -> User:
def create_user(body: UserCreate) -> User:
"""Create a new user and return the created resource."""
global _next_id
user = User(id=_next_id, name=body.name, email=body.email)
user = User(id=_next_id, name=body.name, email=body.email, role=body.role)
_users_db[_next_id] = user
_next_id += 1
return user
Expand Down
298 changes: 298 additions & 0 deletions artifacts/openapi_baseline.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,298 @@
{
"components": {
"schemas": {
"HTTPValidationError": {
"properties": {
"detail": {
"items": {
"$ref": "#/components/schemas/ValidationError"
},
"title": "Detail",
"type": "array"
}
},
"title": "HTTPValidationError",
"type": "object"
},
"HealthResponse": {
"description": "Health-check response.",
"properties": {
"status": {
"description": "Service status",
"examples": [
"ok"
],
"title": "Status",
"type": "string"
}
},
"required": [
"status"
],
"title": "HealthResponse",
"type": "object"
},
"User": {
"description": "Representation of a user returned by the API.",
"properties": {
"email": {
"description": "Email address",
"title": "Email",
"type": "string"
},
"id": {
"description": "Unique user identifier",
"title": "Id",
"type": "integer"
},
"name": {
"description": "Full name of the user",
"title": "Name",
"type": "string"
},
"role": {
"default": "member",
"description": "User role",
"title": "Role",
"type": "string"
}
},
"required": [
"id",
"name",
"email"
],
"title": "User",
"type": "object"
},
"UserCreate": {
"description": "Request body for creating a new user.",
"properties": {
"email": {
"description": "Email address",
"title": "Email",
"type": "string"
},
"name": {
"description": "Full name of the user",
"title": "Name",
"type": "string"
},
"role": {
"default": "member",
"description": "User role",
"title": "Role",
"type": "string"
}
},
"required": [
"name",
"email"
],
"title": "UserCreate",
"type": "object"
},
"ValidationError": {
"properties": {
"ctx": {
"title": "Context",
"type": "object"
},
"input": {
"title": "Input"
},
"loc": {
"items": {
"anyOf": [
{
"type": "string"
},
{
"type": "integer"
}
]
},
"title": "Location",
"type": "array"
},
"msg": {
"title": "Message",
"type": "string"
},
"type": {
"title": "Error Type",
"type": "string"
}
},
"required": [
"loc",
"msg",
"type"
],
"title": "ValidationError",
"type": "object"
}
}
},
"info": {
"description": "A minimal enterprise API used to demonstrate Docs Drift Guard.",
"title": "Enterprise User API",
"version": "1.0.0"
},
"openapi": "3.1.0",
"paths": {
"/health": {
"get": {
"description": "Return the current health status of the service.",
"operationId": "health_check_health_get",
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HealthResponse"
}
}
},
"description": "Successful Response"
}
},
"summary": "Health check",
"tags": [
"health"
]
}
},
"/v1/audit": {
"delete": {
"description": "Clear all recorded mismatches.",
"operationId": "clear_audit_log_v1_audit_delete",
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"additionalProperties": true,
"title": "Response Clear Audit Log V1 Audit Delete",
"type": "object"
}
}
},
"description": "Successful Response"
}
},
"summary": "Clear the audit log",
"tags": [
"audit"
]
},
"get": {
"description": "Return all API call mismatches recorded by the middleware.\nUseful for identifying clients that are using stale field names\nor calling endpoints that don't exist.",
"operationId": "get_audit_log_v1_audit_get",
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"additionalProperties": true,
"title": "Response Get Audit Log V1 Audit Get",
"type": "object"
}
}
},
"description": "Successful Response"
}
},
"summary": "View API call mismatch audit log",
"tags": [
"audit"
]
}
},
"/v1/users": {
"post": {
"description": "Create a new user and return the created resource.",
"operationId": "create_user_v1_users_post",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/UserCreate"
}
}
},
"required": true
},
"responses": {
"201": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/User"
}
}
},
"description": "Successful Response"
},
"422": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
},
"description": "Validation Error"
}
},
"summary": "Create a new user",
"tags": [
"users"
]
}
},
"/v1/users/{user_id}": {
"get": {
"description": "Retrieve a single user by their unique ID.",
"operationId": "get_user_v1_users__user_id__get",
"parameters": [
{
"in": "path",
"name": "user_id",
"required": true,
"schema": {
"title": "User Id",
"type": "integer"
}
}
],
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/User"
}
}
},
"description": "Successful Response"
},
"422": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
},
"description": "Validation Error"
}
},
"summary": "Get a user by ID",
"tags": [
"users"
]
}
}
}
}
Loading