fix: Clean up whitespace and improve code formatting in API Docs server
Some checks failed
Some checks failed
### Summary of Changes - Removed unnecessary whitespace in the `generateUnifiedSpec` function to enhance code readability. - Standardized formatting in the `operationsSorter` function for consistency. ### Expected Results - Improved code clarity and maintainability, making it easier for developers to read and understand the API Docs server code.
This commit is contained in:
@@ -156,7 +156,7 @@ async function generateUnifiedSpec () {
|
|||||||
// Fetch specs from all services
|
// Fetch specs from all services
|
||||||
for (const [serviceKey, service] of Object.entries(SERVICES)) {
|
for (const [serviceKey, service] of Object.entries(SERVICES)) {
|
||||||
const spec = await fetchServiceSpec(serviceKey, service)
|
const spec = await fetchServiceSpec(serviceKey, service)
|
||||||
|
|
||||||
// Collect original tags before modifying them
|
// Collect original tags before modifying them
|
||||||
const subCategories = new Set()
|
const subCategories = new Set()
|
||||||
if (spec.paths) {
|
if (spec.paths) {
|
||||||
@@ -176,13 +176,13 @@ async function generateUnifiedSpec () {
|
|||||||
for (const [path, methods] of Object.entries(spec.paths)) {
|
for (const [path, methods] of Object.entries(spec.paths)) {
|
||||||
const prefixedPath = `/${serviceKey}${path}`
|
const prefixedPath = `/${serviceKey}${path}`
|
||||||
const updatedMethods = {}
|
const updatedMethods = {}
|
||||||
|
|
||||||
for (const [method, operation] of Object.entries(methods)) {
|
for (const [method, operation] of Object.entries(methods)) {
|
||||||
// Use only the main service name as the primary tag
|
// Use only the main service name as the primary tag
|
||||||
// Store original category in metadata for internal organization
|
// Store original category in metadata for internal organization
|
||||||
const originalTags = operation.tags || ['General']
|
const originalTags = operation.tags || ['General']
|
||||||
const category = originalTags[0] || 'General'
|
const category = originalTags[0] || 'General'
|
||||||
|
|
||||||
updatedMethods[method] = {
|
updatedMethods[method] = {
|
||||||
...operation,
|
...operation,
|
||||||
tags: [service.name], // Only main service tag for top-level grouping
|
tags: [service.name], // Only main service tag for top-level grouping
|
||||||
@@ -193,7 +193,7 @@ async function generateUnifiedSpec () {
|
|||||||
'x-category': category
|
'x-category': category
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unifiedSpec.paths[prefixedPath] = updatedMethods
|
unifiedSpec.paths[prefixedPath] = updatedMethods
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -351,11 +351,11 @@ app.get('/', swaggerUi.setup(null, {
|
|||||||
filter: true,
|
filter: true,
|
||||||
showExtensions: true,
|
showExtensions: true,
|
||||||
showCommonExtensions: true,
|
showCommonExtensions: true,
|
||||||
operationsSorter: function(a, b) {
|
operationsSorter: function (a, b) {
|
||||||
// Sort by summary (which includes category tags)
|
// Sort by summary (which includes category tags)
|
||||||
const summaryA = a.get('summary') || '';
|
const summaryA = a.get('summary') || ''
|
||||||
const summaryB = b.get('summary') || '';
|
const summaryB = b.get('summary') || ''
|
||||||
return summaryA.localeCompare(summaryB);
|
return summaryA.localeCompare(summaryB)
|
||||||
},
|
},
|
||||||
tagsSorter: 'alpha'
|
tagsSorter: 'alpha'
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user