Skip to content

Commit 2e466f8

Browse files
Add integration tests for JSON Schema vocabulary, tags, and webhooks
- Implement JSON Schema Vocabulary Integration tests to validate support for JSON Schema 2020-12 features in the API specification. - Create comprehensive tests for OpenAPI tag management, including adding, updating, and removing tags, as well as handling external documentation. - Develop webhook integration tests to ensure proper functionality of webhooks in the OpenAPI document, including adding, updating, and removing webhooks, as well as testing webhook operations and serialization.
1 parent 1d98be5 commit 2e466f8

21 files changed

Lines changed: 3547 additions & 87 deletions

deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@murat/openapi",
33
"exports": "./mod.ts",
4-
"version": "0.1.2",
4+
"version": "0.1.3",
55
"tasks": {
66
"lint": "deno lint",
77
"test": "deno test --allow-all",

deno.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@ developer-friendly way to define OpenAPI specifications for your APIs.
88
- [Getting Started](./getting-started.md)
99
- [EndpointBuilder](./endpoint-builder.md)
1010
- [OpenAPI Schema](./openapi-schema.md)
11+
- [JSON Schema Vocabularies](./json-schema-vocabularies.md)
1112
- [Security](./security.md)
13+
- [Tags](./tags.md)
1214
- [Components](./components.md)
15+
- [Webhooks](./webhooks.md)
1316
- [Examples](./examples.md)
1417

1518
## Overview
@@ -22,6 +25,10 @@ following the OpenAPI 3.1 standard. It provides:
2225
- Tools for serialization to JSON and YAML formats
2326
- Validation rule handling and documentation
2427
- Comprehensive security scheme definitions and requirements
28+
- Tag management for API organization and categorization
29+
- Webhook support for defining asynchronous API callbacks
30+
- Component reusability for schemas, responses, parameters, and webhooks
31+
- Full JSON Schema 2020-12 support with advanced schema vocabularies
2532

2633
## Basic Usage
2734

@@ -56,6 +63,34 @@ const getUserEndpoint = new EndpointBuilder({
5663
// Add the endpoint to the API document
5764
api.addNewEndpoint_("/users/{id}", getUserEndpoint);
5865

66+
// Add a webhook to the API
67+
api.createWebhook("userUpdated", {
68+
summary: "User Updated Notification",
69+
description: "Sent when a user profile is updated",
70+
operations: {
71+
post: {
72+
requestBody: {
73+
content: {
74+
"application/json": {
75+
schema: {
76+
type: "object",
77+
properties: {
78+
userId: { type: "string" },
79+
updatedAt: { type: "string", format: "date-time" },
80+
},
81+
required: ["userId", "updatedAt"],
82+
},
83+
},
84+
},
85+
required: true,
86+
},
87+
responses: {
88+
"200": { description: "Webhook received" },
89+
},
90+
},
91+
},
92+
});
93+
5994
// Export as JSON or YAML
6095
const jsonString = api.getJSONString();
6196
const yamlString = api.getYAMLString();

docs/getting-started.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,32 @@ const getUsersEndpoint = new EndpointBuilder()
8282
openapi.addNewEndpoint_("/users", getUsersEndpoint);
8383
```
8484
85+
### Adding Tags for Organization
86+
87+
Tags help organize and categorize your API operations:
88+
89+
```typescript
90+
// Define tags at the OpenAPI level
91+
openapi.addTag("users", "User management endpoints");
92+
openapi.addTag("products", "Product catalog endpoints");
93+
openapi.addTag("auth", "Authentication and authorization");
94+
95+
// Then reference these tags in your endpoints
96+
const getUsersEndpoint = new EndpointBuilder()
97+
.setOperation("get")
98+
.setTags(["users"]) // Add the "users" tag to this endpoint
99+
.setSummary("Get users");
100+
// ...more endpoint configuration
101+
102+
// Tags can also be added individually
103+
const createProductEndpoint = new EndpointBuilder()
104+
.setOperation("post")
105+
.addTag("products") // Add a single tag
106+
.addTag("admin") // Add another tag
107+
.setSummary("Create product");
108+
// ...more endpoint configuration
109+
```
110+
85111
### Using Components for Reusability
86112
87113
For better organization and to avoid duplication, use the OpenAPI component

docs/index.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,17 @@ your API endpoints, schemas, responses, and more.
1010
- 📚 **OpenAPI 3.1 compatible**: Generate OpenAPI documentation that follows the
1111
latest specification
1212
- 🧩 **Components**: Define reusable schemas, responses, parameters, and more
13+
- 🏷️ **Tags**: Organize your API with descriptive, reusable tags
1314
- 📄 **JSON & YAML output**: Export your documentation in both formats
1415
- 🔄 **Validation**: Associate validation rules with your API documentation
16+
- 🔒 **Security**: Comprehensive security scheme definitions
1517

1618
## Documentation
1719

1820
- [Getting Started](./getting-started.md): Learn how to use Yelix OpenAPI
1921
- [Components](./components.md): Learn how to use reusable components
22+
- [Tags](./tags.md): Learn how to organize your API with tags
23+
- [Security](./security.md): Learn how to secure your API
2024
- [Validation](./validation.md): Learn about validation rules
2125

2226
## Basic Example

0 commit comments

Comments
 (0)