Skip to content

Commit

Permalink
Fetch all tags (#616)
Browse files Browse the repository at this point in the history
  • Loading branch information
mosch authored Jan 29, 2025
1 parent 8365cd7 commit 772fd45
Show file tree
Hide file tree
Showing 3 changed files with 160 additions and 3 deletions.
145 changes: 145 additions & 0 deletions examples/cosmo-cargo/schema/label-v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,20 @@
"url": "https://developers.sh.example.com"
}
},
"tags": [
{
"name": "Labels",
"description": "Endpoints for managing shipping labels. Labels are printable documents that contain:\n\n* Shipping address information\n* Tracking barcodes\n* Carrier-specific routing data\n* Package details"
},
{
"name": "Stamps",
"description": "Endpoints for managing postage stamps. Stamps provide:\n\n* Proof of postage payment\n* Digital verification\n* Support for multiple output formats (PDF, PNG, ZPL)\n* 24-hour validity period"
},
{
"name": "Analytics",
"description": "Endpoints for retrieving shipping analytics and statistics. Analytics provide:\n\n* Shipping volume metrics\n* Cost analysis\n* Delivery performance tracking\n* Regional distribution insights"
}
],
"servers": [
{
"url": "https://api.sh.example.com/v1",
Expand Down Expand Up @@ -324,6 +338,137 @@
}
}
}
},
"/analytics/shipping-volume": {
"get": {
"tags": ["Analytics"],
"summary": "Get shipping volume statistics",
"description": "Retrieves shipping volume statistics for a specified time period. Includes daily, weekly, and monthly aggregations of shipping data.",
"deprecated": true,
"operationId": "getShippingVolumeStats",
"parameters": [
{
"name": "start_date",
"in": "query",
"required": true,
"description": "Start date for the analysis period",
"schema": {
"type": "string",
"format": "date"
},
"example": "2025-01-01"
},
{
"name": "end_date",
"in": "query",
"required": true,
"description": "End date for the analysis period",
"schema": {
"type": "string",
"format": "date"
},
"example": "2025-01-31"
},
{
"name": "grouping",
"in": "query",
"required": false,
"description": "How to group the statistics",
"schema": {
"type": "string",
"enum": ["daily", "weekly", "monthly"],
"default": "daily"
}
}
],
"responses": {
"200": {
"description": "Statistics retrieved successfully",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"period": {
"type": "object",
"properties": {
"start": {
"type": "string",
"format": "date"
},
"end": {
"type": "string",
"format": "date"
}
}
},
"grouping": {
"type": "string",
"enum": ["daily", "weekly", "monthly"]
},
"total_shipments": {
"type": "integer"
},
"data": {
"type": "array",
"items": {
"type": "object",
"properties": {
"date": {
"type": "string",
"format": "date"
},
"shipment_count": {
"type": "integer"
},
"total_weight_kg": {
"type": "number",
"format": "float"
},
"average_cost": {
"type": "number",
"format": "float"
}
}
}
}
}
},
"example": {
"period": {
"start": "2025-01-01",
"end": "2025-01-31"
},
"grouping": "daily",
"total_shipments": 1250,
"data": [
{
"date": "2025-01-01",
"shipment_count": 42,
"total_weight_kg": 156.8,
"average_cost": 12.5
}
]
}
}
}
},
"400": {
"description": "Invalid input parameters",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
},
"example": {
"code": "INVALID_DATE_RANGE",
"message": "End date must be after start date"
}
}
}
}
}
}
}
}
}
12 changes: 11 additions & 1 deletion examples/cosmo-cargo/schema/label-v3.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"openapi": "3.0.3",
"info": {
"title": "Shipping Labels & Stamps API",
"title": "Labels & Stamps API",
"description": "This API allows you to create shipping labels and stamps for your shipments.\n\n## Authentication\nAll endpoints require a valid API key passed in the `X-API-Key` header.\n",
"version": "3.0.0",
"contact": {
Expand All @@ -10,6 +10,16 @@
"url": "https://developers.sh.example.com"
}
},
"tags": [
{
"name": "Labels",
"description": "Endpoints for managing shipping labels. Labels are printable documents that contain:\n\n* Shipping address information\n* Tracking barcodes\n* Carrier-specific routing data\n* Package details"
},
{
"name": "Stamps",
"description": "Endpoints for managing postage stamps. Stamps provide:\n\n* Proof of postage payment\n* Digital verification\n* Support for multiple output formats (PDF, PNG, ZPL)\n* 24-hour validity period"
}
],
"servers": [
{
"url": "https://eedefc50718545d6b3a6cd7ea38faf06_oas.api.mockbin.io/",
Expand Down
6 changes: 4 additions & 2 deletions packages/zudoku/src/vite/plugin-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,11 @@ const viteApiPlugin = async (

const schemas = processedSchemas[apiConfig.navigationId];
if (!schemas?.length) continue;
const latestSchema = schemas[0]?.schema;

const tags = getAllTags(latestSchema).map(({ name }) => name);
const tags = schemas
.flatMap((schema) => getAllTags(schema.schema))
.map(({ name }) => name)
.filter((name, index, array) => array.indexOf(name) === index);

code.push(
"configuredApiPlugins.push(openApiPlugin({",
Expand Down

0 comments on commit 772fd45

Please sign in to comment.