@gomjellie/lazyapi 0.0.1 → 0.0.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/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  ![demo](https://github.com/user-attachments/assets/ed95f068-09da-4226-91fd-430027258b31)
4
4
 
5
+ **⚠️ Work in Progress**
6
+
5
7
  <div align="center">
6
8
 
7
9
  A **Vim-style TUI (Terminal User Interface)** tool for exploring Swagger/OpenAPI documents and testing APIs in the terminal
package/dist/cli.js CHANGED
@@ -9,14 +9,16 @@ import App from './App.js';
9
9
  // 명령줄 인자 파싱
10
10
  const args = process.argv.slice(2);
11
11
  if (args.length === 0) {
12
- console.error('사용법: swagger-cli <file>');
12
+ console.error('사용법: swagger-cli <file-or-url>');
13
13
  console.error('');
14
14
  console.error('예시:');
15
15
  console.error(' swagger-cli openapi.json');
16
- console.error(' swagger-cli swagger.yaml');
16
+ console.error(' swagger-cli https://example.com/openapi.json');
17
17
  process.exit(1);
18
18
  }
19
- const filePath = path.resolve(process.cwd(), args[0]);
19
+ const inputSource = args[0];
20
+ const isUrl = inputSource.startsWith('http://') || inputSource.startsWith('https://');
21
+ const filePath = isUrl ? inputSource : path.resolve(process.cwd(), inputSource);
20
22
  // 터미널 클리어하여 깨끗한 화면에서 시작
21
23
  console.clear();
22
24
  // 앱 렌더링
@@ -5,9 +5,9 @@ import { OpenAPIDocument, Endpoint, HttpMethod } from '../types/openapi.js';
5
5
  import type { OpenAPI } from 'openapi-types';
6
6
  export declare class OpenAPIParserService {
7
7
  /**
8
- * OpenAPI 문서를 파일에서 로드하고 파싱
8
+ * OpenAPI 문서를 파일 또는 URL에서 로드하고 파싱
9
9
  */
10
- parseFromFile(filePath: string): Promise<OpenAPI.Document>;
10
+ parseFromFile(source: string): Promise<OpenAPI.Document>;
11
11
  /**
12
12
  * OpenAPI 문서에서 엔드포인트 목록 추출
13
13
  */
@@ -7,23 +7,26 @@ import path from 'path';
7
7
  import { isOpenAPIV2Document, isReferenceObject, resolveRef, } from '../types/openapi.js';
8
8
  export class OpenAPIParserService {
9
9
  /**
10
- * OpenAPI 문서를 파일에서 로드하고 파싱
10
+ * OpenAPI 문서를 파일 또는 URL에서 로드하고 파싱
11
11
  */
12
- async parseFromFile(filePath) {
12
+ async parseFromFile(source) {
13
13
  try {
14
- // 파일 존재 확인
15
- if (!fs.existsSync(filePath)) {
16
- throw new Error(`파일을 찾을 수 없습니다: ${filePath}`);
17
- }
18
- // 파일 확장자 확인
19
- const ext = path.extname(filePath).toLowerCase();
20
- if (!['.json', '.yaml', '.yml'].includes(ext)) {
21
- throw new Error('지원하지 않는 파일 형식입니다. JSON 또는 YAML 파일만 지원합니다.');
14
+ const isUrl = source.startsWith('http://') || source.startsWith('https://');
15
+ if (!isUrl) {
16
+ // 파일 확장자 확인
17
+ const ext = path.extname(source).toLowerCase();
18
+ if (!['.json', '.yaml', '.yml'].includes(ext)) {
19
+ throw new Error('지원하지 않는 파일 형식입니다. JSON 또는 YAML 파일만 지원합니다.');
20
+ }
21
+ // 파일 존재 확인
22
+ if (!fs.existsSync(source)) {
23
+ throw new Error(`파일을 찾을 수 없습니다: ${source}`);
24
+ }
22
25
  }
23
26
  // SwaggerParser로 문서 파싱
24
27
  // bundle()을 사용하여 $ref를 내부 참조로 유지하면서 외부 파일만 번들링
25
28
  // validate()는 모든 $ref를 resolve하므로 사용하지 않음
26
- const api = await SwaggerParser.bundle(filePath);
29
+ const api = await SwaggerParser.bundle(source);
27
30
  return api;
28
31
  }
29
32
  catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gomjellie/lazyapi",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "A terminal-based Swagger/OpenAPI explorer with Vim-style keyboard navigation",
5
5
  "type": "module",
6
6
  "main": "dist/cli.js",