
Security News
Bun 1.2.19 Adds Isolated Installs for Better Monorepo Support
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.
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
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.
Security News
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.
Security News
Popular npm packages like eslint-config-prettier were compromised after a phishing attack stole a maintainer’s token, spreading malicious updates.
Security News
/Research
A phishing attack targeted developers using a typosquatted npm domain (npnjs.com) to steal credentials via fake login pages - watch out for similar scams.