apigrip 0.3.0 → 0.4.0

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.
@@ -0,0 +1,24 @@
1
+ // cli/commands/spec.js — Print the parsed OpenAPI spec
2
+
3
+ import fs from 'node:fs';
4
+ import { parseSpec } from '../../core/spec-parser.js';
5
+ import { resolveProjectContext } from '../resolve-project.js';
6
+
7
+ export async function specCommand(argv) {
8
+ const { specPath } = await resolveProjectContext(argv);
9
+ if (!specPath) {
10
+ console.error('No spec file found');
11
+ process.exit(2);
12
+ }
13
+ try {
14
+ if (argv.raw) {
15
+ process.stdout.write(fs.readFileSync(specPath, 'utf8'));
16
+ } else {
17
+ const spec = await parseSpec(specPath);
18
+ console.log(JSON.stringify(spec, null, 2));
19
+ }
20
+ } catch (err) {
21
+ console.error(`Spec parse error: ${err.message}`);
22
+ process.exit(2);
23
+ }
24
+ }
package/cli/index.js CHANGED
@@ -96,6 +96,15 @@ const cli = yargs(hideBin(process.argv))
96
96
  const { envCommand } = await import('./commands/env.js');
97
97
  await envCommand(argv);
98
98
  })
99
+ .command('spec', 'Print the parsed OpenAPI spec as JSON', (yargs) => {
100
+ return yargs
101
+ .option('raw', { type: 'boolean', describe: 'Print raw spec file instead of parsed/dereferenced' })
102
+ .option('spec', { type: 'string', describe: 'Path to spec file' })
103
+ .option('project', { type: 'string', describe: 'Project directory' });
104
+ }, async (argv) => {
105
+ const { specCommand } = await import('./commands/spec.js');
106
+ await specCommand(argv);
107
+ })
99
108
  .command('mcp', 'Start MCP server', (yargs) => {
100
109
  return yargs
101
110
  .option('project', { type: 'string' })