
Product
Introducing Scala and Kotlin Support in Socket
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.
swagger-to-interfaces
Advanced tools
Super *lightweight* typescript interface generator. > ✨Generate Typescript interfaces, enums and api endpoints straight from the swagger
Super lightweight typescript interface generator.
✨Generate Typescript interfaces, enums and api endpoints straight from the swagger
WHY ?!
Swagger codegen allows you to generate a whole heavyweight full-blown client.
Most of us frontend developers do not use it.
We want to use our regular flow and loose the hassle of duplicating the server's schema.
swagger-to-interfaces is a lightweight library designed to auto generate only data which is useful.
npm install swagger-to-interfaces
swagger-to-interfaces --pathToFile=/path/to/json/swagger.json --destinationFolderName=./src/swagger2Ts
♢ Arguments: Include the following args on activation:
--destinationFolderName
--pathToFile OR --swaggerUrl
OR
♢ .env file: create a .env file at the root directory of your project with the following variables:
DESTINATION_FOLDER_NAME=./src/swagger2Ts
SWAGGER_FILE_PATH=./swagger.json or SWAGGER_URL=https://petstore.swagger.io/v2/swagger.json
Three files will be created:
♕ interfaces.ts
all model definitions in Typescript interfaces.
♕ endpoints.ts
[operationId: string]: {
method: 'post' | 'get' | 'put' | 'delete';
url?: string;
getUrl?: (...params: any) => string};
contentType?: string;
}
♕ enums.ts
all enum definitions.
♙ Get the swagger json from the server.
♘ Add it to the UI project (for example: /path/to/json/swagger).
♗ Add a hook to your package.json scripts section:
"build-swagger": "swagger-to-typescript --pathToFile=/path/to/json/swagger"
♕ Add this hook to your build process:
"prebuild": "npm run build-swagger"
♔ Make sure to commit your swagger.json, so the UI build is not dependent on external resources.
FAQs
Super *lightweight* typescript interface generator. > ✨Generate Typescript interfaces, enums and api endpoints straight from the swagger
The npm package swagger-to-interfaces receives a total of 37 weekly downloads. As such, swagger-to-interfaces popularity was classified as not popular.
We found that swagger-to-interfaces 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.
Product
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.
Application Security
/Security News
Socket CEO Feross Aboukhadijeh and a16z partner Joel de la Garza discuss vibe coding, AI-driven software development, and how the rise of LLMs, despite their risks, still points toward a more secure and innovative future.
Research
/Security News
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.