api-spec-generator 0.0.14-alpha → 0.0.16-alpha
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/{dist → lib}/OpenApiSpec/openApiSpec.d.ts +0 -1
- package/{dist → lib}/OpenApiSpec/openApiSpec.d.ts.map +1 -1
- package/lib/OpenApiSpec/openApiSpec.js +38 -0
- package/lib/OpenApiSpec/openApiSpec.js.map +1 -0
- package/lib/index.js +6 -0
- package/lib/index.js.map +1 -0
- package/package.json +14 -4
- package/.gitattributes +0 -2
- package/.github/workflows/ci.yml +0 -198
- package/.github/workflows/unit-tests.yml +0 -31
- package/dist/OpenApiSpec/openApiSpec.js +0 -33
- package/dist/OpenApiSpec/openApiSpec.js.map +0 -1
- package/dist/index.js +0 -3
- package/dist/index.js.map +0 -1
- package/jest.config.js +0 -14
- package/src/OpenApiSpec/openApiSpec.js +0 -38
- package/src/OpenApiSpec/openApiSpec.ts +0 -40
- package/src/index.ts +0 -2
- package/tests/OpenApiSpec/openApiSpec.test.ts +0 -23
- package/tsconfig.jest.json +0 -9
- package/tsconfig.json +0 -47
- /package/{dist → lib}/index.d.ts +0 -0
- /package/{dist → lib}/index.d.ts.map +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openApiSpec.d.ts","sourceRoot":"","sources":["../../src/OpenApiSpec/openApiSpec.ts"],"names":[],"mappings":"AAEA,qBAAa,WAAW;IACpB,OAAO,CAAC,OAAO,CAAmB;IAElC,OAAO,CAAC,KAAK,CAAW;IACxB,OAAO,CAAC,UAAU,CAAW;IAC7B,OAAO,CAAC,eAAe,CAAW;IAClC,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,QAAQ,CAA0B;IAC1C,OAAO,CAAC,WAAW,CAAgB;IAC5B,qBAAqB,IAAI,GAAG
|
|
1
|
+
{"version":3,"file":"openApiSpec.d.ts","sourceRoot":"","sources":["../../src/OpenApiSpec/openApiSpec.ts"],"names":[],"mappings":"AAEA,qBAAa,WAAW;IACpB,OAAO,CAAC,OAAO,CAAmB;IAElC,OAAO,CAAC,KAAK,CAAW;IACxB,OAAO,CAAC,UAAU,CAAW;IAC7B,OAAO,CAAC,eAAe,CAAW;IAClC,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,QAAQ,CAA0B;IAC1C,OAAO,CAAC,WAAW,CAAgB;IAC5B,qBAAqB,IAAI,GAAG;IASnC,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAIxC,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAInC,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAIzC,gBAAgB,IAAI,IAAI;CAK3B"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OpenApiSpec = void 0;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
class OpenApiSpec {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.openApi = "3.0.1";
|
|
8
|
+
this.paths = {};
|
|
9
|
+
this.components = {};
|
|
10
|
+
this.securitySchemes = {};
|
|
11
|
+
this.writeToYamlFile = false;
|
|
12
|
+
this.fileName = "openapi-spec";
|
|
13
|
+
this.pathToFiles = "./";
|
|
14
|
+
}
|
|
15
|
+
getOpenApiSpecContent() {
|
|
16
|
+
return {
|
|
17
|
+
openapi: this.openApi,
|
|
18
|
+
paths: this.paths,
|
|
19
|
+
components: this.components,
|
|
20
|
+
securitySchemes: this.securitySchemes
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
setOpenApiVersion(version) {
|
|
24
|
+
this.openApi = version;
|
|
25
|
+
}
|
|
26
|
+
setFileName(fileName) {
|
|
27
|
+
this.fileName = fileName;
|
|
28
|
+
}
|
|
29
|
+
setPathToFiles(pathToFiles) {
|
|
30
|
+
this.pathToFiles = pathToFiles;
|
|
31
|
+
}
|
|
32
|
+
writeOpenApiSpec() {
|
|
33
|
+
const specFileContent = this.getOpenApiSpecContent();
|
|
34
|
+
(0, fs_1.writeFileSync)(`${this.pathToFiles}${this.fileName}.${this.writeToYamlFile ? "yaml" : "json"}`, JSON.stringify(specFileContent, null, 2));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.OpenApiSpec = OpenApiSpec;
|
|
38
|
+
//# sourceMappingURL=openApiSpec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openApiSpec.js","sourceRoot":"","sources":["../../src/OpenApiSpec/openApiSpec.ts"],"names":[],"mappings":";;;AAAA,2BAAmC;AAEnC,MAAa,WAAW;IAAxB;QACY,YAAO,GAAW,OAAO,CAAC;QAE1B,UAAK,GAAQ,EAAE,CAAC;QAChB,eAAU,GAAQ,EAAE,CAAC;QACrB,oBAAe,GAAQ,EAAE,CAAC;QAC1B,oBAAe,GAAY,KAAK,CAAC;QACjC,aAAQ,GAAW,cAAc,CAAC;QAClC,gBAAW,GAAW,IAAI,CAAC;IA2BvC,CAAC;IA1BU,qBAAqB;QACxB,OAAO;YACH,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,eAAe,EAAE,IAAI,CAAC,eAAe;SACxC,CAAA;IACL,CAAC;IAED,iBAAiB,CAAC,OAAe;QAC7B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;IAED,WAAW,CAAC,QAAgB;QACxB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC7B,CAAC;IAED,cAAc,CAAC,WAAmB;QAC9B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACnC,CAAC;IAED,gBAAgB;QACZ,MAAM,eAAe,GAAG,IAAI,CAAC,qBAAqB,EAAE,CAAC;QAErD,IAAA,kBAAa,EAAC,GAAG,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,IAAI,CAAC,SAAS,CAAC,eAAe,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAC7I,CAAC;CACJ;AAnCD,kCAmCC"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OpenApiSpec = void 0;
|
|
4
|
+
const openApiSpec_1 = require("./OpenApiSpec/openApiSpec");
|
|
5
|
+
Object.defineProperty(exports, "OpenApiSpec", { enumerable: true, get: function () { return openApiSpec_1.OpenApiSpec; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,2DAAwD;AAC/C,4FADA,yBAAW,OACA"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "api-spec-generator",
|
|
3
3
|
"description": "",
|
|
4
|
-
"main": "
|
|
5
|
-
"
|
|
4
|
+
"main": "lib/index.js",
|
|
5
|
+
"types": "lib/index.d.ts",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "tsc",
|
|
8
8
|
"test": "jest",
|
|
9
9
|
"test:watch": "jest --watch",
|
|
10
|
-
"test:coverage": "jest --coverage"
|
|
10
|
+
"test:coverage": "jest --coverage",
|
|
11
|
+
"lint": "eslint \"src/**/*.ts\" --fix",
|
|
12
|
+
"lint-ci": "eslint \"src/**/*.ts\""
|
|
11
13
|
},
|
|
12
14
|
"repository": {
|
|
13
15
|
"type": "git",
|
|
@@ -22,11 +24,19 @@
|
|
|
22
24
|
"devDependencies": {
|
|
23
25
|
"@types/jest": "^30.0.0",
|
|
24
26
|
"@types/node": "^25.2.3",
|
|
27
|
+
"eslint": "^9.39.2",
|
|
28
|
+
"neostandard": "^0.12.2",
|
|
25
29
|
"ts-jest": "^29.4.6",
|
|
26
30
|
"typescript": "^5.9.3"
|
|
27
31
|
},
|
|
28
32
|
"dependencies": {
|
|
29
33
|
"zod": "^4.3.6"
|
|
30
34
|
},
|
|
31
|
-
"
|
|
35
|
+
"files": [
|
|
36
|
+
"lib/**/*"
|
|
37
|
+
],
|
|
38
|
+
"bin": {
|
|
39
|
+
"api-spec-generator": "./dist/index.js"
|
|
40
|
+
},
|
|
41
|
+
"version": "0.0.16-alpha"
|
|
32
42
|
}
|
package/.gitattributes
DELETED
package/.github/workflows/ci.yml
DELETED
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
# This is a basic workflow to help you get started with Actions
|
|
2
|
-
|
|
3
|
-
name: CI
|
|
4
|
-
|
|
5
|
-
# Controls when the workflow will run
|
|
6
|
-
on:
|
|
7
|
-
push:
|
|
8
|
-
branches: [ "main" ]
|
|
9
|
-
release:
|
|
10
|
-
types: [published]
|
|
11
|
-
workflow_dispatch:
|
|
12
|
-
inputs:
|
|
13
|
-
bump:
|
|
14
|
-
description: 'Type of version bump: major, minor, or patch'
|
|
15
|
-
required: true
|
|
16
|
-
default: 'patch'
|
|
17
|
-
append_alpha:
|
|
18
|
-
description: 'Append -alpha to the new version (true/false)'
|
|
19
|
-
required: false
|
|
20
|
-
default: 'true'
|
|
21
|
-
|
|
22
|
-
jobs:
|
|
23
|
-
bump-version:
|
|
24
|
-
name: Bump version, tag and create release
|
|
25
|
-
runs-on: ubuntu-latest
|
|
26
|
-
permissions:
|
|
27
|
-
contents: write
|
|
28
|
-
steps:
|
|
29
|
-
- name: Checkout
|
|
30
|
-
uses: actions/checkout@v4
|
|
31
|
-
with:
|
|
32
|
-
fetch-depth: 0
|
|
33
|
-
|
|
34
|
-
- name: Setup Node.js
|
|
35
|
-
uses: actions/setup-node@v4
|
|
36
|
-
with:
|
|
37
|
-
node-version: '22'
|
|
38
|
-
|
|
39
|
-
- name: Compute next tag from git tags
|
|
40
|
-
id: bump
|
|
41
|
-
uses: actions/github-script@v7
|
|
42
|
-
with:
|
|
43
|
-
script: |
|
|
44
|
-
const { execSync } = require('child_process');
|
|
45
|
-
const fs = require('fs');
|
|
46
|
-
|
|
47
|
-
// Get environment variables with defaults
|
|
48
|
-
const bumpType = process.env.BUMP_TYPE || 'patch';
|
|
49
|
-
const appendAlpha = process.env.APPEND_ALPHA || 'true';
|
|
50
|
-
|
|
51
|
-
console.log('Bump type:', bumpType);
|
|
52
|
-
|
|
53
|
-
// Validate BUMP_TYPE
|
|
54
|
-
if (!['major', 'minor', 'patch'].includes(bumpType)) {
|
|
55
|
-
throw new Error(`Invalid bump type: ${bumpType}`);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Fetch tags
|
|
59
|
-
execSync('git fetch --tags');
|
|
60
|
-
|
|
61
|
-
// Get latest tag
|
|
62
|
-
let latestTag = '';
|
|
63
|
-
try {
|
|
64
|
-
latestTag = execSync('git tag --list "v*" --sort=-v:refname | head -n1', { encoding: 'utf8' }).trim();
|
|
65
|
-
} catch (e) {
|
|
66
|
-
latestTag = '';
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (!latestTag) {
|
|
70
|
-
latestTag = 'v0.0.0';
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
console.log('Latest tag:', latestTag);
|
|
74
|
-
|
|
75
|
-
// Parse version
|
|
76
|
-
let ver = latestTag.substring(1); // Remove 'v' prefix
|
|
77
|
-
const baseVer = ver.split('-')[0]; // Strip prerelease (e.g. -alpha)
|
|
78
|
-
|
|
79
|
-
let [maj, min, pat] = baseVer.split('.').map(x => parseInt(x) || 0);
|
|
80
|
-
|
|
81
|
-
// Bump version
|
|
82
|
-
switch (bumpType) {
|
|
83
|
-
case 'major':
|
|
84
|
-
maj++; min = 0; pat = 0;
|
|
85
|
-
break;
|
|
86
|
-
case 'minor':
|
|
87
|
-
min++; pat = 0;
|
|
88
|
-
break;
|
|
89
|
-
case 'patch':
|
|
90
|
-
pat++;
|
|
91
|
-
break;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const newBase = `${maj}.${min}.${pat}`;
|
|
95
|
-
const newVer = appendAlpha === 'true' ? `${newBase}-alpha` : newBase;
|
|
96
|
-
|
|
97
|
-
console.log('New version:', newVer);
|
|
98
|
-
|
|
99
|
-
// Set output for next steps
|
|
100
|
-
core.setOutput('version', newVer);
|
|
101
|
-
env:
|
|
102
|
-
BUMP_TYPE: ${{ github.event.inputs.bump }}
|
|
103
|
-
APPEND_ALPHA: ${{ github.event.inputs.append_alpha }}
|
|
104
|
-
|
|
105
|
-
- name: Create and push tag
|
|
106
|
-
run: |
|
|
107
|
-
git config user.name "github-actions[bot]"
|
|
108
|
-
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
109
|
-
TAG=v${{ steps.bump.outputs.version }}
|
|
110
|
-
COMMIT_MSG=$(git log -1 --pretty=%B)
|
|
111
|
-
echo "Creating tag $TAG"
|
|
112
|
-
git tag -a "$TAG" -m "$COMMIT_MSG"
|
|
113
|
-
git push origin "$TAG"
|
|
114
|
-
|
|
115
|
-
- name: Create GitHub release
|
|
116
|
-
uses: actions/create-release@v1
|
|
117
|
-
with:
|
|
118
|
-
tag_name: v${{ steps.bump.outputs.version }}
|
|
119
|
-
release_name: v${{ steps.bump.outputs.version }}
|
|
120
|
-
body: "Release ${{ steps.bump.outputs.version }} (automated)"
|
|
121
|
-
env:
|
|
122
|
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
123
|
-
|
|
124
|
-
publish:
|
|
125
|
-
needs: bump-version
|
|
126
|
-
runs-on: ubuntu-latest
|
|
127
|
-
permissions:
|
|
128
|
-
contents: read
|
|
129
|
-
steps:
|
|
130
|
-
- name: Checkout
|
|
131
|
-
uses: actions/checkout@v4
|
|
132
|
-
with:
|
|
133
|
-
fetch-depth: 0
|
|
134
|
-
|
|
135
|
-
- name: Get latest tag
|
|
136
|
-
uses: actions/github-script@v7
|
|
137
|
-
id: get-tag
|
|
138
|
-
with:
|
|
139
|
-
script: |
|
|
140
|
-
const { execSync } = require('child_process');
|
|
141
|
-
|
|
142
|
-
// Get the latest tag
|
|
143
|
-
let latestTag = '';
|
|
144
|
-
try {
|
|
145
|
-
latestTag = execSync('git describe --tags $(git rev-list --tags --max-count=1)', { encoding: 'utf8' }).trim();
|
|
146
|
-
} catch (e) {
|
|
147
|
-
console.log('No tags found');
|
|
148
|
-
latestTag = '';
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
console.log('Latest tag:', latestTag);
|
|
152
|
-
core.setOutput('tag', latestTag);
|
|
153
|
-
|
|
154
|
-
if (!latestTag) {
|
|
155
|
-
core.setFailed('No tag found');
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
- name: Setup Node.js
|
|
159
|
-
uses: actions/setup-node@v4
|
|
160
|
-
with:
|
|
161
|
-
node-version: '22'
|
|
162
|
-
registry-url: 'https://registry.npmjs.org'
|
|
163
|
-
|
|
164
|
-
- name: Install dependencies
|
|
165
|
-
run: npm ci
|
|
166
|
-
|
|
167
|
-
- name: Build
|
|
168
|
-
run: npm run build
|
|
169
|
-
|
|
170
|
-
- name: Add version to package.json
|
|
171
|
-
uses: actions/github-script@v7
|
|
172
|
-
with:
|
|
173
|
-
script: |
|
|
174
|
-
const fs = require('fs');
|
|
175
|
-
const path = require('path');
|
|
176
|
-
|
|
177
|
-
const tagName = '${{ steps.get-tag.outputs.tag }}';
|
|
178
|
-
console.log('Setting version from tag:', tagName);
|
|
179
|
-
|
|
180
|
-
// Remove 'v' prefix if present
|
|
181
|
-
const version = tagName.startsWith('v') ? tagName.slice(1) : tagName;
|
|
182
|
-
|
|
183
|
-
// Read package.json
|
|
184
|
-
const packageJsonPath = path.join(process.cwd(), 'package.json');
|
|
185
|
-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
186
|
-
|
|
187
|
-
// Update version
|
|
188
|
-
packageJson.version = version;
|
|
189
|
-
|
|
190
|
-
// Write back
|
|
191
|
-
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n');
|
|
192
|
-
|
|
193
|
-
console.log('Updated package.json version to:', version);
|
|
194
|
-
|
|
195
|
-
- name: Publish to npm
|
|
196
|
-
run: npm publish
|
|
197
|
-
env:
|
|
198
|
-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
name: Build and Test
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
pull_request:
|
|
5
|
-
branches: [main]
|
|
6
|
-
|
|
7
|
-
jobs:
|
|
8
|
-
build-and-test:
|
|
9
|
-
runs-on: ubuntu-latest
|
|
10
|
-
|
|
11
|
-
strategy:
|
|
12
|
-
matrix:
|
|
13
|
-
node-version: [22.x]
|
|
14
|
-
|
|
15
|
-
steps:
|
|
16
|
-
- uses: actions/checkout@v4
|
|
17
|
-
|
|
18
|
-
- name: Use Node.js ${{ matrix.node-version }}
|
|
19
|
-
uses: actions/setup-node@v4
|
|
20
|
-
with:
|
|
21
|
-
node-version: ${{ matrix.node-version }}
|
|
22
|
-
cache: 'npm'
|
|
23
|
-
|
|
24
|
-
- name: Install dependencies
|
|
25
|
-
run: npm ci
|
|
26
|
-
|
|
27
|
-
- name: Build
|
|
28
|
-
run: npm run build
|
|
29
|
-
|
|
30
|
-
- name: Run tests
|
|
31
|
-
run: npm t
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { writeFileSync } from "fs";
|
|
2
|
-
export class OpenApiSpec {
|
|
3
|
-
openApi = "3.0.1";
|
|
4
|
-
paths = {};
|
|
5
|
-
components = {};
|
|
6
|
-
securitySchemes = {};
|
|
7
|
-
writeToYamlFile = false;
|
|
8
|
-
fileName = "openapi-spec";
|
|
9
|
-
pathToFiles = "./";
|
|
10
|
-
getOpenApiSpecContent() {
|
|
11
|
-
return {
|
|
12
|
-
openapi: this.openApi,
|
|
13
|
-
paths: this.paths,
|
|
14
|
-
components: this.components,
|
|
15
|
-
securitySchemes: this.securitySchemes
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
constructor() { }
|
|
19
|
-
setOpenApiVersion(version) {
|
|
20
|
-
this.openApi = version;
|
|
21
|
-
}
|
|
22
|
-
setFileName(fileName) {
|
|
23
|
-
this.fileName = fileName;
|
|
24
|
-
}
|
|
25
|
-
setPathToFiles(pathToFiles) {
|
|
26
|
-
this.pathToFiles = pathToFiles;
|
|
27
|
-
}
|
|
28
|
-
writeOpenApiSpec() {
|
|
29
|
-
const specFileContent = this.getOpenApiSpecContent();
|
|
30
|
-
writeFileSync(`${this.pathToFiles}${this.fileName}.${this.writeToYamlFile ? "yaml" : "json"}`, JSON.stringify(specFileContent, null, 2));
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
//# sourceMappingURL=openApiSpec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"openApiSpec.js","sourceRoot":"","sources":["../../src/OpenApiSpec/openApiSpec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAEnC,MAAM,OAAO,WAAW;IACZ,OAAO,GAAW,OAAO,CAAC;IAE1B,KAAK,GAAQ,EAAE,CAAC;IAChB,UAAU,GAAQ,EAAE,CAAC;IACrB,eAAe,GAAQ,EAAE,CAAC;IAC1B,eAAe,GAAY,KAAK,CAAC;IACjC,QAAQ,GAAW,cAAc,CAAC;IAClC,WAAW,GAAW,IAAI,CAAC;IAC5B,qBAAqB;QACxB,OAAO;YACH,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,eAAe,EAAE,IAAI,CAAC,eAAe;SACxC,CAAA;IACL,CAAC;IAED,gBAAe,CAAC;IAEhB,iBAAiB,CAAC,OAAe;QAC7B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;IAED,WAAW,CAAC,QAAgB;QACxB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC7B,CAAC;IAED,cAAc,CAAC,WAAmB;QAC9B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACnC,CAAC;IAED,gBAAgB;QACZ,MAAM,eAAe,GAAG,IAAI,CAAC,qBAAqB,EAAE,CAAC;QAErD,aAAa,CAAC,GAAG,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,IAAI,CAAC,SAAS,CAAC,eAAe,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAC7I,CAAC;CACJ"}
|
package/dist/index.js
DELETED
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
package/jest.config.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
preset: "ts-jest",
|
|
3
|
-
testEnvironment: "node",
|
|
4
|
-
testRegex: ".*\\.test\\.ts$",
|
|
5
|
-
extensionsToTreatAsEsm: [".ts"],
|
|
6
|
-
transform: {
|
|
7
|
-
"^.+\\.tsx?$": ["ts-jest", { useESM: true, tsconfig: "tsconfig.jest.json" }],
|
|
8
|
-
},
|
|
9
|
-
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
|
|
10
|
-
collectCoverageFrom: [
|
|
11
|
-
"src/**/*.ts",
|
|
12
|
-
"!src/**/*.d.ts",
|
|
13
|
-
],
|
|
14
|
-
};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OpenApiSpec = void 0;
|
|
4
|
-
var fs_1 = require("fs");
|
|
5
|
-
var OpenApiSpec = /** @class */ (function () {
|
|
6
|
-
function OpenApiSpec() {
|
|
7
|
-
this.openApi = "3.0.1";
|
|
8
|
-
this.paths = {};
|
|
9
|
-
this.components = {};
|
|
10
|
-
this.securitySchemes = {};
|
|
11
|
-
this.writeToYamlFile = false;
|
|
12
|
-
this.fileName = "openapi-spec";
|
|
13
|
-
this.pathToFiles = "./";
|
|
14
|
-
}
|
|
15
|
-
OpenApiSpec.prototype.getOpenApiSpecContent = function () {
|
|
16
|
-
return {
|
|
17
|
-
openapi: this.openApi,
|
|
18
|
-
paths: this.paths,
|
|
19
|
-
components: this.components,
|
|
20
|
-
securitySchemes: this.securitySchemes
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
OpenApiSpec.prototype.setOpenApiVersion = function (version) {
|
|
24
|
-
this.openApi = version;
|
|
25
|
-
};
|
|
26
|
-
OpenApiSpec.prototype.setFileName = function (fileName) {
|
|
27
|
-
this.fileName = fileName;
|
|
28
|
-
};
|
|
29
|
-
OpenApiSpec.prototype.setPathToFiles = function (pathToFiles) {
|
|
30
|
-
this.pathToFiles = pathToFiles;
|
|
31
|
-
};
|
|
32
|
-
OpenApiSpec.prototype.writeOpenApiSpec = function () {
|
|
33
|
-
var specFileContent = this.getOpenApiSpecContent();
|
|
34
|
-
(0, fs_1.writeFileSync)("".concat(this.pathToFiles).concat(this.fileName, ".").concat(this.writeToYamlFile ? "yaml" : "json"), JSON.stringify(specFileContent, null, 2));
|
|
35
|
-
};
|
|
36
|
-
return OpenApiSpec;
|
|
37
|
-
}());
|
|
38
|
-
exports.OpenApiSpec = OpenApiSpec;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { writeFileSync } from "fs";
|
|
2
|
-
|
|
3
|
-
export class OpenApiSpec {
|
|
4
|
-
private openApi: string = "3.0.1";
|
|
5
|
-
|
|
6
|
-
private paths: any = {};
|
|
7
|
-
private components: any = {};
|
|
8
|
-
private securitySchemes: any = {};
|
|
9
|
-
private writeToYamlFile: boolean = false;
|
|
10
|
-
private fileName: string = "openapi-spec";
|
|
11
|
-
private pathToFiles: string = "./";
|
|
12
|
-
public getOpenApiSpecContent(): any {
|
|
13
|
-
return {
|
|
14
|
-
openapi: this.openApi,
|
|
15
|
-
paths: this.paths,
|
|
16
|
-
components: this.components,
|
|
17
|
-
securitySchemes: this.securitySchemes
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
constructor() {}
|
|
22
|
-
|
|
23
|
-
setOpenApiVersion(version: string): void {
|
|
24
|
-
this.openApi = version;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
setFileName(fileName: string): void {
|
|
28
|
-
this.fileName = fileName;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
setPathToFiles(pathToFiles: string): void {
|
|
32
|
-
this.pathToFiles = pathToFiles;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
writeOpenApiSpec(): void {
|
|
36
|
-
const specFileContent = this.getOpenApiSpecContent();
|
|
37
|
-
|
|
38
|
-
writeFileSync(`${this.pathToFiles}${this.fileName}.${this.writeToYamlFile ? "yaml" : "json"}`, JSON.stringify(specFileContent, null, 2));
|
|
39
|
-
}
|
|
40
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { OpenApiSpec } from "../../src/index.ts";
|
|
2
|
-
|
|
3
|
-
describe("OpenApiSpec", () => {
|
|
4
|
-
let spec: OpenApiSpec;
|
|
5
|
-
|
|
6
|
-
beforeEach(() => {
|
|
7
|
-
spec = new OpenApiSpec();
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it("should initialize with default OpenAPI version 3.0.1", () => {
|
|
11
|
-
// Note: You may need to make the openApi property public or add a getter to test this
|
|
12
|
-
|
|
13
|
-
const content = spec.getOpenApiSpecContent();
|
|
14
|
-
expect(content).toEqual({components: {}, openapi: "3.0.1", paths: {}, securitySchemes: {}});
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it("should allow setting OpenAPI version", () => {
|
|
18
|
-
spec.setOpenApiVersion("3.1.0");
|
|
19
|
-
// Note: You may need to add a getter to verify this
|
|
20
|
-
const content = spec.getOpenApiSpecContent();
|
|
21
|
-
expect(content).toEqual({components: {}, openapi: "3.1.0", paths: {}, securitySchemes: {}});
|
|
22
|
-
});
|
|
23
|
-
});
|
package/tsconfig.jest.json
DELETED
package/tsconfig.json
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
// Visit https://aka.ms/tsconfig to read more about this file
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
// File Layout
|
|
5
|
-
"rootDir": "./src",
|
|
6
|
-
"outDir": "./dist",
|
|
7
|
-
|
|
8
|
-
// Environment Settings
|
|
9
|
-
// See also https://aka.ms/tsconfig/module
|
|
10
|
-
"module": "preserve",
|
|
11
|
-
"target": "esnext",
|
|
12
|
-
"types": ["node", "jest"],
|
|
13
|
-
// For nodejs:
|
|
14
|
-
// "lib": ["esnext"],
|
|
15
|
-
// "types": ["node"],
|
|
16
|
-
// and npm install -D @types/node
|
|
17
|
-
|
|
18
|
-
// Other Outputs
|
|
19
|
-
"sourceMap": true,
|
|
20
|
-
"declaration": true,
|
|
21
|
-
"declarationMap": true,
|
|
22
|
-
"noEmit": false,
|
|
23
|
-
|
|
24
|
-
// Stricter Typechecking Options
|
|
25
|
-
"noUncheckedIndexedAccess": true,
|
|
26
|
-
"exactOptionalPropertyTypes": true,
|
|
27
|
-
|
|
28
|
-
// Style Options
|
|
29
|
-
// "noImplicitReturns": true,
|
|
30
|
-
// "noImplicitOverride": true,
|
|
31
|
-
// "noUnusedLocals": true,
|
|
32
|
-
// "noUnusedParameters": true,
|
|
33
|
-
// "noFallthroughCasesInSwitch": true,
|
|
34
|
-
// "noPropertyAccessFromIndexSignature": true,
|
|
35
|
-
|
|
36
|
-
// Recommended Options
|
|
37
|
-
"strict": true,
|
|
38
|
-
"jsx": "react-jsx",
|
|
39
|
-
"verbatimModuleSyntax": true,
|
|
40
|
-
"isolatedModules": true,
|
|
41
|
-
"noUncheckedSideEffectImports": true,
|
|
42
|
-
"moduleDetection": "force",
|
|
43
|
-
"skipLibCheck": true,
|
|
44
|
-
"moduleResolution": "bundler"
|
|
45
|
-
},
|
|
46
|
-
"exclude": ["tests", "node_modules", "dist"]
|
|
47
|
-
}
|
/package/{dist → lib}/index.d.ts
RENAMED
|
File without changes
|
|
File without changes
|