Gathering detailed insights and metrics for openapi-codegen-typescript
Gathering detailed insights and metrics for openapi-codegen-typescript
Gathering detailed insights and metrics for openapi-codegen-typescript
Gathering detailed insights and metrics for openapi-codegen-typescript
openapi-typescript
Convert OpenAPI 3.0 & 3.1 schemas to TypeScript
openapi-typescript-codegen
Library that generates Typescript clients based on the OpenAPI specification.
@openapi-codegen/typescript
OpenAPI Codegen typescript generators
@pakholeung37/openapi-typescript-codegen
Library that generates Typescript clients based on the OpenAPI specification.
npm install openapi-codegen-typescript
Typescript
Module System
TypeScript (98.83%)
JavaScript (0.75%)
Dockerfile (0.42%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
87 Commits
13 Watchers
10 Branches
39 Contributors
Updated on Apr 24, 2024
Latest Version
0.1.29
Package Id
openapi-codegen-typescript@0.1.29
Unpacked Size
137.30 kB
Size
23.00 kB
File Count
106
Published on
Apr 24, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
4
yarn add -D openapi-codegen-typescript
npm install openapi-codegen-typescript --save-dev
What is this library for?
1const { fetchSwaggerJsonFile } = require('openapi-codegen-typescript'); 2 3async function doSomething() { 4 const json = await fetchSwaggerJsonFile('https://custom/swagger.json'); 5 console.log('Json Result', json); 6}
1const { fetchSwaggerJsonFile, convertToTypes } = require('openapi-codegen-typescript'); 2 3async function doSomething() { 4 const json = await fetchSwaggerJsonFile('https://custom/swagger.json'); 5 convertToTypes({ json, fileName: 'dtoAPI', folderPath: 'src/types/generated' }); 6}
This function ('doSomething()') fetches json file from urls, then converts json to typescript "types" and writes "types" to file ('src/types/generated/dtoAPI')
1const { fetchSwaggerJsonFile, convertToTypes } = require('openapi-codegen-typescript'); 2 3async function doSomething() { 4 const json = await fetchSwaggerJsonFile('https://custom/swagger.json'); 5 convertToMocks({ 6 json, 7 fileName: 'dtoAPI', 8 folderPath: 'src/mocks/generated', 9 typesPath: '../../types/generated/dtoAPI', 10 }); 11}
This function ('doSomething()') fetches json file from urls, then converts json to "mocks" and writes "mocks" to file ('src/mocks/generated/dtoAPI') with imports from typescript types ('src/types/generated/dtoAPI')
You can override open-api enum types and mocks by specifying overrideSchemas
prop.
Let's imagine that we have this schema enum type in a json file:
1{ 2 "SomeType": { 3 "type": "string", 4 "description": "", 5 "x-enumNames": ["Audio", "Video", "Image", "Text", "Raw"], 6 "enum": ["Audio", "Video", "Image", "Text", "Raw"] 7 } 8}
Overriding example:
1const { fetchSwaggerJsonFile, convertToTypes, convertToMocks } = require('openapi-codegen-typescript'); 2 3const url = 'https://someLinkToSwagger/v2/swagger.json'; 4 5async function main() { 6 const json = await fetchSwaggerJsonFile(url); 7 const overrideSchemas = [ 8 { 9 ServiceOfferKind: { 10 type: 'string', 11 description: 'Warning! This type is overrided', 12 enum: ['masteringAndDistribution', 'video', 'samples', 'mastering', 'distribution', 'sessions'], 13 }, 14 }, 15 ]; 16 17 convertToTypes({ 18 json, 19 fileName: 'typesAPI', 20 folderPath: 'src/types/generated', 21 overrideSchemas, 22 }); 23 convertToMocks({ 24 json, 25 fileName: 'mocksAPI', 26 folderPath: 'src/mocks/generated', 27 typesPath: '../../types/generated/typesAPI', 28 overrideSchemas, 29 }); 30} 31 32main();
1const { fetchSwaggerJsonFile, convertToTypes, convertToMocks } = require('openapi-codegen-typescript'); 2 3const petShopLink = 'https://petstore.swagger.io/v2/swagger.json'; 4 5async function main() { 6 const json = await fetchSwaggerJsonFile(petShopLink); 7 convertToTypes({ json, fileName: 'typesAPI', folderPath: 'src/types/generated' }); 8 convertToMocks({ 9 json, 10 fileName: 'mocksAPI', 11 folderPath: 'src/mocks/generated', 12 typesPath: '../../types/generated/typesAPI', 13 }); 14} 15 16main();
url
: string
- url to swagger json file
Returns a swagger json object;
json
: object
- swagger json data;
fileName
: string
- name of the file, where typescript types data will be saved;
folderPath
: string
- folder path the fileName
, where typescript types data will be saved;
Returns void
;
json
: object
- swagger json data;
fileName
: string
- name of the file, where mocks data will be saved;
folderPath
: string
- folder path the fileName
, where mocks data will be saved;
typesPath
: string
- folder path to types
, where typescript types data are saved.
Path to types
will be inserted to the type imports in generated mocks (generated -> import {...} from typesPath
;);
Returns void
;
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 5/24 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
34 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More