
Security News
Risky Biz Podcast: Making Reachability Analysis Work in Real-World Codebases
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
ts-from-swagger
Advanced tools
Generate TypeScript interfaces and enums quickly and easily from Swagger definition JSON with our lightweight tool. Improve your development workflow by automatically generating type-safe code that's easy to maintain and understand. Say goodbye to manual
Generate TypeScript interfaces and enums quickly and easily from Swagger definition JSON with our lightweight tool. Improve your development workflow by automatically generating type-safe code that's easy to maintain and understand. Say goodbye to manual coding and hello to streamlined development with our Swagger definition Typescript generator.
keywords: ts-from-swagger, swagger2ts, typescript generator, type-safe, type-safe rest Apis, type safety, TypeScript interfaces generator, Swagger to TypeScript converter, NPM package for generating TypeScript interfaces from Swagger, TypeScript definitions from Swagger, Swagger JSON to TypeScript, TypeScript code from Swagger schema, TypeScript typings from Swagger definition, Swagger interface to TypeScript conversion, TypeScript enum generator from Swagger JSON, TypeScript code generation from Swagger definition., Convert Swagger JSON to TypeScript code, tsgen.
#npm
npm i ts-from-swagger --save-dev
#yarn
yarn add ts-from-swagger --dev
Specify your swagger JSON url and followed by output directory(default is: ./src/definitions
)
npx ts-from-swagger https://petstore.swagger.io/v2/swagger.json ./path/to/output/dir
Or add a script to your package.json file:
"scripts": {
"ts-from-swagger": "npx ts-from-swagger https://petstore.swagger.io/v2/swagger.json ./path/to/output/dir"
}
Then run the script with npm run:
npm run ts-from-swagger
Write types safe code from your frontend to your backend API, backend agnostic as long as you use Swagger.
import axios from "axios";
import { PetStatus } from "./definitions/enums/PetStatus.enum";
import { Category } from "./definitions/interfaces/Category.interface";
import { Pet } from "./definitions/interfaces/Pet.interface";
import { Tag } from "./definitions/interfaces/Tag.interface";
const cats: Category = {
id: 1,
name: "Cats",
};
const friendly: Tag = {
id: 1,
name: "friendly",
};
const mellow: Tag = {
id: 2,
name: "mellow",
};
const newPet: Pet = {
id: 123,
name: "Mischievous",
category: cats,
// photoUrls: ["https://picsum.photos/200"], // not required
tags: [friendly, mellow],
status: PetStatus.AVAILABLE,
};
axios
.post("https://petstore.swagger.io/v2/pet", newPet)
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.error(error);
});
- Initial Version 1.0.0 : 11/03/2023
- Project Setup.
- Theory & prove of concept.
- Alpha Version 1.0.1 : 13/03/2023
- CLI configuration.
- Generate Enums.
- Fix Wrong type for arrays.
- Fix OutputPath make recursive.
- Beta Version 1.0.2 : 15/03/2023
- Fix Imports.
- Make Subfolders.
- Respect naming conventions.
- Refactor Code.
- Beta Version 1.0.3 : 17/03/2023
- Add simple CLI logs.
- Fix run npx: node v14.21.1 / npm v6.14.17
- [Agenda] Beta Version 1.0.x : xx/03/2023
- Add Authorization.
- Add support for Swagger version 3.
- Add support for YML.
- Fix issue: npx command on later node/npm versions.
Contributions are welcome! If you find a bug or have a feature request, please open an issue on the GitHub repository.
Tests included:
npm test
This project is licensed under the MIT License. See the LICENSE file for more information. Feel free to use it in your own projects, or contribute to its development on GitHub.
FAQs
Generate TypeScript interfaces and enums quickly and easily from Swagger definition JSON with our lightweight tool. Improve your development workflow by automatically generating type-safe code that's easy to maintain and understand. Say goodbye to manual
The npm package ts-from-swagger receives a total of 0 weekly downloads. As such, ts-from-swagger popularity was classified as not popular.
We found that ts-from-swagger demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.