![38% of CISOs Fear They’re Not Moving Fast Enough on AI](https://cdn.sanity.io/images/cgdhsj6q/production/faa0bc28df98f791e11263f8239b34207f84b86f-1024x1024.webp?w=400&fit=max&auto=format)
Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
api-typescript-generator
Advanced tools
Generates OpenAPI TypeScript client. Extremely fast and flexible.
Generates OpenAPI client for TypeScript. Extremely configurable.
fetch
API for making HTTP requests by default, but can be configured to use any other HTTP client.Install using npm
npm add --save-dev api-typescript-generator
Or using yarn
yarn add --dev api-typescript-generator
Create a api-typescript-generator.config.ts
file in the root of your project.
import path from 'path';
import {ApiTypescriptGeneratorConfig} from 'api-typescript-generator';
const configuration: ApiTypescriptGeneratorConfig = {
generates: [
{
type: 'openapiClient',
document: {
// The source of the OpenAPI document.
// Can also be { type: 'file', path: 'path/to/file.yaml' }
// Both YAML and JSON formats are supported.
source: {
type: 'url',
url: 'https://raw.githubusercontent.com/readmeio/oas-examples/main/3.1/yaml/petstore.yaml'
}
},
// The output directory for the generated client.
outputDirPath: path.join(__dirname, 'petstore-api-client'),
client: {
// The name of the generated client class.
name: 'PetStoreApiClient',
// Overrides the default base URL for the API.
baseUrl: 'https://petstore.swagger.io/v2'
}
}
]
};
export default configuration;
Add the following script to your package.json
:
{
// ...
"scripts": {
// ...
"openapi-codegen": "api-typescript-generator generate api-typescript-generator.config.ts"
}
}
Run the script:
npm run openapi-codegen
Or using yarn:
yarn openapi-codegen
By default it generates:
models
directory by default.services
directory by default.core
directory by default.The generated client can be used as follows:
import {PetStoreApiClient} from './petstore-api-client';
async function testApiClient() {
const apiClient = new PetStoreApiClient();
console.log(await client.store.getInventory());
}
testApiClient().catch(console.error);
The most important interface for now would be the OpenApiClientGeneratorConfig interface. It contains all the configuration options for the OpenAPI Client Generator.
Types are exported as part of three modules, depending on the area of application:
api-typescript-generator
- The main module that exports the common API Generator Configuration types.api-typescript-generator/openapi-client
- The module that exports the OpenAPI Client Generator Configuration types.api-typescript-generator/openapi
- The module that exports the OpenAPI Document types.At the moment only types are exported to be used with CLI. Callable API is planned for the future.
FAQs
Generates OpenAPI TypeScript client. Extremely fast and flexible.
The npm package api-typescript-generator receives a total of 0 weekly downloads. As such, api-typescript-generator popularity was classified as not popular.
We found that api-typescript-generator demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.