@unispechq/unispec-schema 0.4.2 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +31 -10
  2. package/examples/README.md +38 -109
  3. package/examples/invalid/config/empty-services-array.json +4 -0
  4. package/examples/invalid/config/invalid-spec-reference.json +13 -0
  5. package/examples/invalid/config/missing-service-name.json +8 -21
  6. package/examples/invalid/config/missing-services.json +3 -0
  7. package/examples/invalid/config/missing-version.json +8 -5
  8. package/examples/invalid/spec/graphql-missing-arg-type.json +21 -0
  9. package/examples/invalid/spec/graphql-missing-name.json +22 -0
  10. package/examples/invalid/spec/invalid-identifier.json +23 -0
  11. package/examples/invalid/spec/invalid-rest-method.json +22 -0
  12. package/examples/invalid/spec/missing-service-name.json +22 -0
  13. package/examples/invalid/spec/missing-unispec-version.json +22 -0
  14. package/examples/valid/config/complete-enterprise.json +142 -0
  15. package/examples/valid/config/registry-based.json +40 -0
  16. package/examples/valid/config/simple-multi-service.json +58 -0
  17. package/examples/valid/spec/graphql-simple.json +48 -0
  18. package/examples/valid/spec/mixed-complete.json +163 -0
  19. package/examples/valid/spec/rest-simple.json +45 -0
  20. package/examples/valid/spec/websocket-simple.json +71 -0
  21. package/package.json +2 -2
  22. package/examples/invalid/config/additional-properties.json +0 -26
  23. package/examples/invalid/graphql-additional-properties.json +0 -22
  24. package/examples/invalid/graphql-missing-arg-type.json +0 -26
  25. package/examples/invalid/graphql-missing-name.json +0 -19
  26. package/examples/invalid/graphql-missing-schema.json +0 -19
  27. package/examples/invalid/mixed-invalid-protocol.json +0 -26
  28. package/examples/invalid/mixed-missing-graphql-schema.json +0 -33
  29. package/examples/invalid/mixed-multiple-errors.json +0 -41
  30. package/examples/invalid/rest-additional-properties.json +0 -25
  31. package/examples/invalid/rest-invalid-identifiers.json +0 -29
  32. package/examples/invalid/rest-invalid-method.json +0 -23
  33. package/examples/invalid/rest-missing-required.json +0 -21
  34. package/examples/invalid/websocket-additional-properties.json +0 -27
  35. package/examples/invalid/websocket-invalid-direction.json +0 -27
  36. package/examples/invalid/websocket-missing-channel-name.json +0 -25
  37. package/examples/invalid/websocket-missing-message-name.json +0 -25
  38. package/examples/valid/config/complete.json +0 -61
  39. package/examples/valid/config/minimal.json +0 -8
  40. package/examples/valid/graphql-complete.json +0 -348
  41. package/examples/valid/graphql-simple.json +0 -34
  42. package/examples/valid/mixed-complete.json +0 -799
  43. package/examples/valid/mixed-simple.json +0 -56
  44. package/examples/valid/rest-complete.json +0 -539
  45. package/examples/valid/rest-simple.json +0 -279
  46. package/examples/valid/websocket-complete.json +0 -471
  47. package/examples/valid/websocket-simple.json +0 -116
@@ -0,0 +1,48 @@
1
+ {
2
+ "unispecVersion": "1.0.0",
3
+ "service": {
4
+ "name": "blog-service",
5
+ "description": "A blog service with GraphQL API",
6
+ "version": "1.0.0",
7
+ "baseUrl": "https://blog.example.com",
8
+ "protocols": {
9
+ "graphql": {
10
+ "url": "/graphql",
11
+ "schema": "type User { id: ID! username: String! email: String! posts: [Post!]! } type Post { id: ID! title: String! content: String! author: User! createdAt: String! } type Query { user(id: ID!): User posts: [Post!]! } type Mutation { createPost(title: String!, content: String!): Post! }",
12
+ "queries": [
13
+ {
14
+ "name": "user",
15
+ "description": "Get user by ID",
16
+ "args": [
17
+ {
18
+ "name": "id",
19
+ "type": "ID!",
20
+ "description": "User ID"
21
+ }
22
+ ],
23
+ "returnType": "User"
24
+ }
25
+ ],
26
+ "mutations": [
27
+ {
28
+ "name": "createPost",
29
+ "description": "Create a new post",
30
+ "args": [
31
+ {
32
+ "name": "title",
33
+ "type": "String!",
34
+ "description": "Post title"
35
+ },
36
+ {
37
+ "name": "content",
38
+ "type": "String!",
39
+ "description": "Post content"
40
+ }
41
+ ],
42
+ "returnType": "Post!"
43
+ }
44
+ ]
45
+ }
46
+ }
47
+ }
48
+ }
@@ -0,0 +1,163 @@
1
+ {
2
+ "unispecVersion": "1.0.0",
3
+ "service": {
4
+ "name": "ecommerce-service",
5
+ "description": "A complete e-commerce service with multiple protocols",
6
+ "version": "2.1.0",
7
+ "baseUrl": "https://api.ecommerce.com",
8
+ "contact": {
9
+ "name": "API Team",
10
+ "email": "api@ecommerce.com"
11
+ },
12
+ "license": {
13
+ "name": "Apache 2.0",
14
+ "url": "https://opensource.org/licenses/Apache-2.0"
15
+ },
16
+ "tags": [
17
+ "ecommerce",
18
+ "rest",
19
+ "graphql",
20
+ "websocket"
21
+ ],
22
+ "protocols": {
23
+ "rest": {
24
+ "routes": [
25
+ {
26
+ "name": "getProducts",
27
+ "summary": "Get all products",
28
+ "path": "/products",
29
+ "method": "GET",
30
+ "responses": {
31
+ "200": {
32
+ "description": "Products retrieved successfully"
33
+ }
34
+ }
35
+ },
36
+ {
37
+ "name": "createOrder",
38
+ "summary": "Create new order",
39
+ "path": "/orders",
40
+ "method": "POST",
41
+ "requestBody": {
42
+ "required": true,
43
+ "content": {
44
+ "application/json": {
45
+ "schemaRef": "CreateOrderRequest"
46
+ }
47
+ }
48
+ },
49
+ "responses": {
50
+ "201": {
51
+ "description": "Order created successfully"
52
+ }
53
+ }
54
+ }
55
+ ]
56
+ },
57
+ "graphql": {
58
+ "url": "/graphql",
59
+ "schema": "type Product { id: ID! name: String! price: Float! } type Order { id: ID! products: [Product!]! total: Float! } type Query { products: [Product!]! order(id: ID!): Order }",
60
+ "queries": [
61
+ {
62
+ "name": "products",
63
+ "description": "Get all products",
64
+ "returnType": "[Product!]!"
65
+ }
66
+ ],
67
+ "mutations": [
68
+ {
69
+ "name": "createOrder",
70
+ "description": "Create a new order",
71
+ "args": [
72
+ {
73
+ "name": "productIds",
74
+ "type": "[ID!]!"
75
+ }
76
+ ],
77
+ "returnType": "Order!"
78
+ }
79
+ ]
80
+ },
81
+ "websocket": {
82
+ "url": "/ws",
83
+ "channels": [
84
+ {
85
+ "name": "orderUpdates",
86
+ "description": "Real-time order updates",
87
+ "direction": "subscribe",
88
+ "messages": [
89
+ {
90
+ "name": "orderStatusUpdate",
91
+ "description": "Order status update",
92
+ "schemaRef": "OrderStatusUpdate"
93
+ }
94
+ ]
95
+ }
96
+ ]
97
+ }
98
+ },
99
+ "schemas": {
100
+ "CreateOrderRequest": {
101
+ "description": "Request to create an order",
102
+ "jsonSchema": {
103
+ "type": "object",
104
+ "properties": {
105
+ "productIds": {
106
+ "type": "array",
107
+ "items": {
108
+ "type": "string"
109
+ }
110
+ },
111
+ "customerId": {
112
+ "type": "string"
113
+ }
114
+ },
115
+ "required": [
116
+ "productIds",
117
+ "customerId"
118
+ ]
119
+ }
120
+ },
121
+ "OrderStatusUpdate": {
122
+ "description": "Order status update message",
123
+ "jsonSchema": {
124
+ "type": "object",
125
+ "properties": {
126
+ "orderId": {
127
+ "type": "string"
128
+ },
129
+ "status": {
130
+ "type": "string",
131
+ "enum": [
132
+ "pending",
133
+ "processing",
134
+ "shipped",
135
+ "delivered"
136
+ ]
137
+ },
138
+ "timestamp": {
139
+ "type": "string",
140
+ "format": "date-time"
141
+ }
142
+ },
143
+ "required": [
144
+ "orderId",
145
+ "status",
146
+ "timestamp"
147
+ ]
148
+ }
149
+ }
150
+ },
151
+ "securitySchemes": {
152
+ "bearerAuth": {
153
+ "type": "http",
154
+ "scheme": "bearer",
155
+ "bearerFormat": "JWT"
156
+ }
157
+ },
158
+ "rateLimit": {
159
+ "requestsPerMinute": 100,
160
+ "perUser": true
161
+ }
162
+ }
163
+ }
@@ -0,0 +1,45 @@
1
+ {
2
+ "unispecVersion": "1.0.0",
3
+ "service": {
4
+ "name": "user-service",
5
+ "description": "A simple user management service with REST API",
6
+ "version": "1.2.3",
7
+ "baseUrl": "https://api.example.com",
8
+ "protocols": {
9
+ "rest": {
10
+ "routes": [
11
+ {
12
+ "name": "getUsers",
13
+ "summary": "Get all users",
14
+ "path": "/users",
15
+ "method": "GET",
16
+ "responses": {
17
+ "200": {
18
+ "description": "List of users retrieved successfully"
19
+ }
20
+ }
21
+ },
22
+ {
23
+ "name": "createUser",
24
+ "summary": "Create a new user",
25
+ "path": "/users",
26
+ "method": "POST",
27
+ "requestBody": {
28
+ "required": true,
29
+ "content": {
30
+ "application/json": {
31
+ "schemaRef": "CreateUserRequest"
32
+ }
33
+ }
34
+ },
35
+ "responses": {
36
+ "201": {
37
+ "description": "User created successfully"
38
+ }
39
+ }
40
+ }
41
+ ]
42
+ }
43
+ }
44
+ }
45
+ }
@@ -0,0 +1,71 @@
1
+ {
2
+ "unispecVersion": "1.0.0",
3
+ "service": {
4
+ "name": "chat-service",
5
+ "description": "A chat service with WebSocket API",
6
+ "version": "1.0.0",
7
+ "baseUrl": "https://chat.example.com",
8
+ "protocols": {
9
+ "websocket": {
10
+ "url": "/ws",
11
+ "channels": [
12
+ {
13
+ "name": "messages",
14
+ "description": "Chat messages channel",
15
+ "namespace": "chat",
16
+ "direction": "both",
17
+ "messages": [
18
+ {
19
+ "name": "sendMessage",
20
+ "description": "Send a message",
21
+ "direction": "publish",
22
+ "schemaRef": "ChatMessage"
23
+ },
24
+ {
25
+ "name": "receiveMessage",
26
+ "description": "Receive a message",
27
+ "direction": "subscribe",
28
+ "schemaRef": "ChatMessage"
29
+ }
30
+ ]
31
+ }
32
+ ]
33
+ }
34
+ },
35
+ "schemas": {
36
+ "ChatMessage": {
37
+ "description": "Chat message",
38
+ "jsonSchema": {
39
+ "type": "object",
40
+ "properties": {
41
+ "id": {
42
+ "type": "string",
43
+ "format": "uuid"
44
+ },
45
+ "userId": {
46
+ "type": "string",
47
+ "format": "uuid"
48
+ },
49
+ "username": {
50
+ "type": "string"
51
+ },
52
+ "message": {
53
+ "type": "string"
54
+ },
55
+ "timestamp": {
56
+ "type": "string",
57
+ "format": "date-time"
58
+ }
59
+ },
60
+ "required": [
61
+ "id",
62
+ "userId",
63
+ "username",
64
+ "message",
65
+ "timestamp"
66
+ ]
67
+ }
68
+ }
69
+ }
70
+ }
71
+ }
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@unispechq/unispec-schema",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "Official UniSpec JSON Schemas",
5
5
  "type": "module",
6
6
  "main": "index.cjs",
7
7
  "module": "index.mjs",
8
8
  "types": "index.d.ts",
9
9
  "scripts": {
10
- "lint": "pnpm run biome check --write --unsafe",
10
+ "lint": "biome check --write --unsafe",
11
11
  "release:patch": "node scripts/release.js patch",
12
12
  "release:minor": "node scripts/release.js minor",
13
13
  "release:major": "node scripts/release.js major"
@@ -1,26 +0,0 @@
1
- {
2
- "unispecVersion": "0.1.0",
3
- "service": {
4
- "name": "config-api",
5
- "description": "API with additional properties",
6
- "invalidProperty": "should not exist",
7
- "protocols": {
8
- "rest": {
9
- "routes": [
10
- {
11
- "name": "getUsers",
12
- "path": "/users",
13
- "method": "GET",
14
- "responses": {
15
- "200": {
16
- "description": "Success",
17
- "invalidProperty": "should not exist"
18
- }
19
- }
20
- }
21
- ],
22
- "invalidProperty": "should not exist"
23
- }
24
- }
25
- }
26
- }
@@ -1,22 +0,0 @@
1
- {
2
- "unispecVersion": "0.1.0",
3
- "service": {
4
- "name": "invalid-graphql-api",
5
- "description": "GraphQL API with additional properties",
6
- "protocols": {
7
- "graphql": {
8
- "url": "/graphql",
9
- "schema": "type Query {\n users: [User!]!\n}\n\ntype User {\n id: ID!\n name: String!\n}\n",
10
- "queries": [
11
- {
12
- "name": "users",
13
- "description": "Get users",
14
- "returnType": "[User!]!",
15
- "invalidProperty": "should not exist"
16
- }
17
- ],
18
- "invalidProperty": "should not exist"
19
- }
20
- }
21
- }
22
- }
@@ -1,26 +0,0 @@
1
- {
2
- "unispecVersion": "0.1.0",
3
- "service": {
4
- "name": "invalid-graphql-api",
5
- "description": "GraphQL API with missing argument type",
6
- "protocols": {
7
- "graphql": {
8
- "url": "/graphql",
9
- "schema": "type Query {\n users(limit: Int): [User!]!\n}\n\ntype User {\n id: ID!\n name: String!\n}\n",
10
- "queries": [
11
- {
12
- "name": "users",
13
- "description": "Get users",
14
- "args": [
15
- {
16
- "name": "limit",
17
- "description": "Limit number of results"
18
- }
19
- ],
20
- "returnType": "[User!]!"
21
- }
22
- ]
23
- }
24
- }
25
- }
26
- }
@@ -1,19 +0,0 @@
1
- {
2
- "unispecVersion": "0.1.0",
3
- "service": {
4
- "name": "invalid-graphql-api",
5
- "description": "GraphQL API with missing operation name",
6
- "protocols": {
7
- "graphql": {
8
- "url": "/graphql",
9
- "schema": "type Query {\n users: [User!]!\n}\n\ntype User {\n id: ID!\n name: String!\n}\n",
10
- "queries": [
11
- {
12
- "description": "Get users",
13
- "returnType": "[User!]!"
14
- }
15
- ]
16
- }
17
- }
18
- }
19
- }
@@ -1,19 +0,0 @@
1
- {
2
- "unispecVersion": "0.1.0",
3
- "service": {
4
- "name": "invalid-graphql-api",
5
- "description": "GraphQL API missing required schema field",
6
- "protocols": {
7
- "graphql": {
8
- "url": "/graphql",
9
- "queries": [
10
- {
11
- "name": "users",
12
- "description": "Get users",
13
- "returnType": "[User!]!"
14
- }
15
- ]
16
- }
17
- }
18
- }
19
- }
@@ -1,26 +0,0 @@
1
- {
2
- "unispecVersion": "0.1.0",
3
- "service": {
4
- "name": "invalid-mixed-api",
5
- "description": "Mixed protocol API with invalid protocol",
6
- "protocols": {
7
- "rest": {
8
- "routes": [
9
- {
10
- "name": "getUsers",
11
- "path": "/users",
12
- "method": "GET",
13
- "responses": {
14
- "200": {
15
- "description": "Success"
16
- }
17
- }
18
- }
19
- ]
20
- },
21
- "invalidProtocol": {
22
- "someProperty": "value"
23
- }
24
- }
25
- }
26
- }
@@ -1,33 +0,0 @@
1
- {
2
- "unispecVersion": "0.1.0",
3
- "service": {
4
- "name": "invalid-mixed-api",
5
- "description": "Mixed protocol API missing GraphQL schema",
6
- "protocols": {
7
- "rest": {
8
- "routes": [
9
- {
10
- "name": "getUsers",
11
- "path": "/users",
12
- "method": "GET",
13
- "responses": {
14
- "200": {
15
- "description": "Success"
16
- }
17
- }
18
- }
19
- ]
20
- },
21
- "graphql": {
22
- "url": "/graphql",
23
- "queries": [
24
- {
25
- "name": "users",
26
- "description": "Get users",
27
- "returnType": "[User!]!"
28
- }
29
- ]
30
- }
31
- }
32
- }
33
- }
@@ -1,41 +0,0 @@
1
- {
2
- "unispecVersion": "0.1.0",
3
- "service": {
4
- "description": "API with multiple errors",
5
- "protocols": {
6
- "rest": {
7
- "routes": [
8
- {
9
- "name": "",
10
- "method": "INVALID",
11
- "responses": {
12
- "200": {
13
- "description": "Success"
14
- }
15
- }
16
- }
17
- ]
18
- },
19
- "graphql": {
20
- "queries": [
21
- {
22
- "description": "Missing name",
23
- "returnType": "[User!]!"
24
- }
25
- ]
26
- },
27
- "websocket": {
28
- "channels": [
29
- {
30
- "messages": [
31
- {
32
- "description": "Missing name",
33
- "direction": "invalid"
34
- }
35
- ]
36
- }
37
- ]
38
- }
39
- }
40
- }
41
- }
@@ -1,25 +0,0 @@
1
- {
2
- "unispecVersion": "0.1.0",
3
- "service": {
4
- "name": "extra-props-api",
5
- "description": "API with additional properties",
6
- "protocols": {
7
- "rest": {
8
- "routes": [
9
- {
10
- "name": "getUsers",
11
- "path": "/users",
12
- "method": "GET",
13
- "invalidProperty": "should not exist",
14
- "responses": {
15
- "200": {
16
- "description": "Success",
17
- "invalidProperty": "should not exist"
18
- }
19
- }
20
- }
21
- ]
22
- }
23
- }
24
- }
25
- }
@@ -1,29 +0,0 @@
1
- {
2
- "unispecVersion": "0.1.0",
3
- "service": {
4
- "name": "invalid-name-with-spaces",
5
- "description": "API with invalid service name",
6
- "protocols": {
7
- "rest": {
8
- "routes": [
9
- {
10
- "name": "route with spaces",
11
- "path": "/test",
12
- "method": "GET",
13
- "queryParams": [
14
- {
15
- "name": "param with spaces",
16
- "required": false
17
- }
18
- ],
19
- "responses": {
20
- "200": {
21
- "description": "Success"
22
- }
23
- }
24
- }
25
- ]
26
- }
27
- }
28
- }
29
- }
@@ -1,23 +0,0 @@
1
- {
2
- "unispecVersion": "0.1.0",
3
- "service": {
4
- "name": "invalid-method-api",
5
- "description": "API with invalid HTTP method",
6
- "protocols": {
7
- "rest": {
8
- "routes": [
9
- {
10
- "name": "invalidMethod",
11
- "path": "/test",
12
- "method": "INVALID",
13
- "responses": {
14
- "200": {
15
- "description": "Success"
16
- }
17
- }
18
- }
19
- ]
20
- }
21
- }
22
- }
23
- }
@@ -1,21 +0,0 @@
1
- {
2
- "unispecVersion": "0.1.0",
3
- "service": {
4
- "description": "API with missing required fields",
5
- "protocols": {
6
- "rest": {
7
- "routes": [
8
- {
9
- "name": "getUsers",
10
- "method": "GET",
11
- "responses": {
12
- "200": {
13
- "description": "Success"
14
- }
15
- }
16
- }
17
- ]
18
- }
19
- }
20
- }
21
- }