Skip to content

Commit

Permalink
test: added test for verifying changed component section identification
Browse files Browse the repository at this point in the history
  • Loading branch information
shenbenson committed Jan 28, 2025
1 parent 571a7a1 commit dc5589a
Show file tree
Hide file tree
Showing 3 changed files with 165 additions and 0 deletions.
81 changes: 81 additions & 0 deletions tests/fixtures/component-section/current.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"openapi": "3.0.0",
"info": {
"title": "Test API",
"description": "A sample API for testing"
},
"servers": [
{
"url": "https://api.example.com/v1"
}
],
"paths": {
"/user/{id}": {
"get": {
"summary": "Get user by ID",
"parameters": [
{
"$ref": "#/components/parameters/StringUserId"
},
{
"$ref": "#/components/parameters/NumberUserId"
}
],
"responses": {
"200": {
"description": "User found",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"userCreated": {
"type": "array",
"items": {
"$ref": "#/components/schemas/User"
}
}
}
}
}
}
}
}
}
}
},
"components": {
"parameters": {
"StringUserId": {
"type": "string",
"description": "The unique identifier for a user",
"example": 1234
},
"NumberUserId": {
"type": "number",
"description": "The unique identifier for a user",
"example": 1234
}
},
"schemas": {
"User": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"email": {
"$ref": "#/components/schemas/Email"
}
}
},
"Email": {
"type": "string",
"format": "email"
}
}
}
}
4 changes: 4 additions & 0 deletions tests/fixtures/component-section/expected.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## Modified
- [GET] `/user/{id}`
- `NumberUserId` modified in parameters
- `User` modified in responses
80 changes: 80 additions & 0 deletions tests/fixtures/component-section/previous.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{
"openapi": "3.0.0",
"info": {
"title": "Test API",
"description": "A sample API for testing"
},
"servers": [
{
"url": "https://api.example.com/v1"
}
],
"paths": {
"/user/{id}": {
"get": {
"summary": "Get user by ID",
"parameters": [
{
"$ref": "#/components/parameters/StringUserId"
},
{
"$ref": "#/components/parameters/NumberUserId"
}
],
"responses": {
"200": {
"description": "User found",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"userCreated": {
"type": "array",
"items": {
"$ref": "#/components/schemas/User"
}
}
}
}
}
}
}
}
}
}
},
"components": {
"parameters": {
"StringUserId": {
"type": "string",
"description": "The unique identifier for a user",
"example": 1234
},
"NumberUserId": {
"type": "number",
"description": "The unique identifier for a user",
"example": 12345
}
},
"schemas": {
"User": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"email": {
"$ref": "#/components/schemas/Email"
}
}
},
"Email": {
"type": "string"
}
}
}
}

0 comments on commit dc5589a

Please sign in to comment.