@stackql/provider-utils 0.2.1 → 0.2.2

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackql/provider-utils",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Utilities for building StackQL providers from OpenAPI specifications.",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -18,10 +18,11 @@ export async function generateDocs(options) {
18
18
  console.log(`documenting ${providerName}...`);
19
19
 
20
20
  const docsDir = path.join(outputDir, `docs`);
21
+ const servicesDir = path.join(docsDir, `services`);
21
22
 
22
23
  // Remove directory if it exists, then create it fresh
23
24
  fs.existsSync(docsDir) && fs.rmSync(docsDir, { recursive: true, force: true });
24
- fs.mkdirSync(docsDir, { recursive: true });
25
+ fs.mkdirSync(servicesDir, { recursive: true });
25
26
 
26
27
  // Check for provider data files
27
28
  console.log(providerDataDir);
@@ -58,16 +59,16 @@ export async function generateDocs(options) {
58
59
  servicesForIndex.push(serviceName);
59
60
  const filePath = path.join(serviceDir, file);
60
61
  totalServicesCount++;
61
- const serviceFolder = `${docsDir}/${serviceName}`;
62
+ const serviceFolder = `${servicesDir}/${serviceName}`;
62
63
  await createDocsForService(filePath, providerName, serviceName, serviceFolder);
63
64
  }
64
65
 
65
66
  console.log(`Processed ${totalServicesCount} services`);
66
67
 
67
68
  // Count total resources
68
- totalResourcesCount = fs.readdirSync(`${docsDir}`, { withFileTypes: true })
69
+ totalResourcesCount = fs.readdirSync(`${servicesDir}`, { withFileTypes: true })
69
70
  .filter(dirent => dirent.isDirectory())
70
- .map(dirent => fs.readdirSync(`${docsDir}/${dirent.name}`).length)
71
+ .map(dirent => fs.readdirSync(`${servicesDir}/${dirent.name}`).length)
71
72
  .reduce((a, b) => a + b, 0);
72
73
 
73
74
  console.log(`Processed ${totalResourcesCount} resources`);
@@ -264,12 +265,12 @@ ${secondColumnLinks}
264
265
  function generateResourceLinks(providerName, serviceName, resources) {
265
266
  // Generate resource links for the service index
266
267
  const resourceLinks = resources.map((resource) => {
267
- return `<a href="/${serviceName}/${resource.name}/">${resource.name}</a>`;
268
+ return `<a href="/services/${serviceName}/${resource.name}/">${resource.name}</a>`;
268
269
  });
269
270
  return resourceLinks.join('<br />\n');
270
271
  }
271
272
 
272
273
  // Function to convert services to markdown links
273
274
  function servicesToMarkdown(providerName, servicesList) {
274
- return servicesList.map(service => `<a href="/${service}/">${service}</a><br />`).join('\n');
275
+ return servicesList.map(service => `<a href="/services/${service}/">${service}</a><br />`).join('\n');
275
276
  }
@@ -386,30 +386,37 @@ function getHttpOperationInfo(dereferencedAPI, path, httpVerb, mediaType, openAP
386
386
  }
387
387
 
388
388
  const schema = responseObj.content[mediaType].schema;
389
-
389
+
390
+ const { respProps, respDescription } = getHttpRespBody(schema, objectKey);
391
+
392
+ return {
393
+ respProps,
394
+ respDescription: responseObj.description ? responseObj.description : respDescription,
395
+ opDescription,
396
+ requestBody
397
+ };
398
+ }
399
+
400
+ function getHttpRespBody(schema, objectKey) {
401
+
390
402
  if (schema.type === 'array') {
391
403
  return {
392
- respProps: schema.items.properties || {},
393
- respDescription: schema.items.description || responseObj.description || '',
394
- opDescription,
395
- requestBody
396
- };
404
+ respProps: schema.items.properties || {},
405
+ respDescription: schema.items.description || '',
406
+ }
397
407
  } else if (schema.type === 'object') {
398
408
  return {
399
- respProps: schema.properties || {},
400
- respDescription: schema.description || responseObj.description || '',
401
- opDescription,
402
- requestBody
409
+ respProps: schema.properties || {},
410
+ respDescription: schema.description || '',
403
411
  };
404
412
  } else {
405
- // For primitive types or when schema structure is unexpected
406
413
  return {
407
414
  respProps: {},
408
- respDescription: schema.description || responseObj.description || '',
409
- opDescription,
410
- requestBody
415
+ respDescription: '',
411
416
  };
412
417
  }
418
+
419
+
413
420
  }
414
421
 
415
422
  function getHttpOperationParams(dereferencedAPI, path, httpVerb) {