Skip to content

Commit 8c22736

Browse files
committed
feat(nx-plugin): enhance OpenAPI spec comparison functionality
- Replace the existing openapi-diff dependency with api-smart-diff for improved comparison accuracy. - Add comprehensive test cases to validate spec comparison logic across various scenarios.
1 parent 69f6254 commit 8c22736

17 files changed

+4453
-2403
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
"turbo": "2.5.0",
7272
"typescript": "5.8.3",
7373
"typescript-eslint": "8.29.1",
74+
"vite-tsconfig-paths": "5.1.4",
7475
"vitest": "3.1.1"
7576
},
7677
"packageManager": "[email protected]+sha512.1acb565e6193efbebda772702950469150cf12bcc764262e7587e71d19dc98a423dff9536e57ea44c49bdf790ff694e83c27be5faa23d67e0c033b583be4bfcf"

packages/nx-plugin/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@
4848
"executors": "./executors.json",
4949
"generators": "./generators.json",
5050
"dependencies": {
51-
"@hey-api/json-schema-ref-parser": "1.0.4",
51+
"@hey-api/json-schema-ref-parser": "1.0.5",
5252
"@hey-api/openapi-ts": "workspace:*",
53-
"@nx/devkit": "20.7.2",
53+
"@nx/devkit": "20.8.1",
5454
"latest-version": "9.0.0",
55-
"openapi-diff": "0.23.7",
55+
"api-smart-diff": "^1.0.6",
5656
"tslib": "2.8.1",
5757
"xcurl": "2.1.2"
5858
},
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
{
2+
"openapi": "3.0.0",
3+
"info": {
4+
"title": "Test API",
5+
"version": "1.0.0",
6+
"description": "A test API for testing spec comparison"
7+
},
8+
"servers": [
9+
{
10+
"url": "https://api.example.com/v1",
11+
"description": "Production server"
12+
}
13+
],
14+
"security": [
15+
{
16+
"apiKey": []
17+
}
18+
],
19+
"paths": {
20+
"/users": {
21+
"get": {
22+
"summary": "Get all users",
23+
"parameters": [
24+
{
25+
"name": "limit",
26+
"in": "query",
27+
"description": "Number of users to return",
28+
"required": false,
29+
"schema": {
30+
"type": "integer",
31+
"default": 10
32+
}
33+
}
34+
],
35+
"responses": {
36+
"200": {
37+
"description": "Successful response",
38+
"content": {
39+
"application/json": {
40+
"schema": {
41+
"type": "array",
42+
"items": {
43+
"$ref": "#/components/schemas/User"
44+
}
45+
},
46+
"example": [
47+
{
48+
"id": 1,
49+
"name": "John Doe"
50+
}
51+
]
52+
}
53+
}
54+
}
55+
}
56+
}
57+
}
58+
},
59+
"components": {
60+
"schemas": {
61+
"User": {
62+
"type": "object",
63+
"properties": {
64+
"id": {
65+
"type": "integer"
66+
},
67+
"name": {
68+
"type": "string"
69+
}
70+
}
71+
}
72+
},
73+
"securitySchemes": {
74+
"apiKey": {
75+
"type": "apiKey",
76+
"name": "X-API-Key",
77+
"in": "header"
78+
}
79+
}
80+
}
81+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
openapi: 3.0.0
2+
info:
3+
title: Test API
4+
version: 1.0.0
5+
description: A test API for testing spec comparison
6+
servers:
7+
- url: https://api.example.com/v1
8+
description: Production server
9+
security:
10+
- apiKey: []
11+
paths:
12+
/users:
13+
get:
14+
summary: Get all users
15+
parameters:
16+
- name: limit
17+
in: query
18+
description: Number of users to return
19+
required: false
20+
schema:
21+
type: integer
22+
default: 10
23+
responses:
24+
'200':
25+
description: Successful response
26+
content:
27+
application/json:
28+
schema:
29+
type: array
30+
items:
31+
$ref: '#/components/schemas/User'
32+
example:
33+
- id: 1
34+
name: John Doe
35+
components:
36+
schemas:
37+
User:
38+
type: object
39+
properties:
40+
id:
41+
type: integer
42+
name:
43+
type: string
44+
securitySchemes:
45+
apiKey:
46+
type: apiKey
47+
name: X-API-Key
48+
in: header
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
{
2+
"openapi": "3.0.0",
3+
"info": {
4+
"title": "Test API",
5+
"version": "1.0.0",
6+
"description": "A test API for testing spec comparison"
7+
},
8+
"servers": [
9+
{
10+
"url": "https://api.example.com/v1",
11+
"description": "Production server"
12+
}
13+
],
14+
"security": [
15+
{
16+
"apiKey": []
17+
}
18+
],
19+
"paths": {
20+
"/users": {
21+
"get": {
22+
"summary": "Get all users",
23+
"parameters": [
24+
{
25+
"name": "limit",
26+
"in": "query",
27+
"description": "Number of users to return",
28+
"required": false,
29+
"schema": {
30+
"type": "integer",
31+
"default": 10
32+
}
33+
}
34+
],
35+
"responses": {
36+
"200": {
37+
"description": "Successful response",
38+
"content": {
39+
"application/json": {
40+
"schema": {
41+
"type": "array",
42+
"items": {
43+
"$ref": "#/components/schemas/User"
44+
}
45+
},
46+
"example": [
47+
{
48+
"id": 1,
49+
"name": "John Doe"
50+
}
51+
]
52+
}
53+
}
54+
}
55+
}
56+
},
57+
"post": {
58+
"summary": "Create a new user",
59+
"requestBody": {
60+
"required": true,
61+
"content": {
62+
"application/json": {
63+
"schema": {
64+
"$ref": "#/components/schemas/User"
65+
}
66+
}
67+
}
68+
},
69+
"responses": {
70+
"201": {
71+
"description": "User created successfully",
72+
"content": {
73+
"application/json": {
74+
"schema": {
75+
"$ref": "#/components/schemas/User"
76+
}
77+
}
78+
}
79+
}
80+
}
81+
}
82+
}
83+
},
84+
"components": {
85+
"schemas": {
86+
"User": {
87+
"type": "object",
88+
"properties": {
89+
"id": {
90+
"type": "integer"
91+
},
92+
"name": {
93+
"type": "string"
94+
}
95+
}
96+
}
97+
},
98+
"securitySchemes": {
99+
"apiKey": {
100+
"type": "apiKey",
101+
"name": "X-API-Key",
102+
"in": "header"
103+
}
104+
}
105+
}
106+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
openapi: 3.0.0
2+
info:
3+
title: Test API
4+
version: 1.0.0
5+
description: A test API for testing spec comparison
6+
servers:
7+
- url: https://api.example.com/v1
8+
description: Production server
9+
security:
10+
- apiKey: []
11+
paths:
12+
/users:
13+
get:
14+
summary: Get all users
15+
parameters:
16+
- name: limit
17+
in: query
18+
description: Number of users to return
19+
required: false
20+
schema:
21+
type: integer
22+
default: 10
23+
responses:
24+
'200':
25+
description: Successful response
26+
content:
27+
application/json:
28+
schema:
29+
type: array
30+
items:
31+
$ref: '#/components/schemas/User'
32+
example:
33+
- id: 1
34+
name: John Doe
35+
post:
36+
summary: Create a new user
37+
requestBody:
38+
required: true
39+
content:
40+
application/json:
41+
schema:
42+
$ref: '#/components/schemas/User'
43+
responses:
44+
'201':
45+
description: User created successfully
46+
content:
47+
application/json:
48+
schema:
49+
$ref: '#/components/schemas/User'
50+
components:
51+
schemas:
52+
User:
53+
type: object
54+
properties:
55+
id:
56+
type: integer
57+
name:
58+
type: string
59+
securitySchemes:
60+
apiKey:
61+
type: apiKey
62+
name: X-API-Key
63+
in: header

0 commit comments

Comments
 (0)