npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

swagger-nodegen-cli

v3.0.34

Published

A simple convenience package that wraps the swagger-codegen-cli for the node/npm environment.

Downloads

1,759

Readme

swagger-nodegen-cli

A convenience package for the node/npm environment that wraps the Java library swagger-codegen-cli

Prerequisites

The following dependencies would need to be installed on your machine before running the Swagger Codegen.

  • Java, version 7 or higher
  • The Java execution path must be on your environment variable PATH

Important Note

The current version of swagger-codegen-cli-3.x.x supports fewer languages ​​than the older versions (2.x.x):

Available languages: [dart, aspnetcore, csharp, csharp-dotnet2, 
go, go-server, dynamic-html, html, html2, java, 
jaxrs-cxf-client, jaxrs-cxf, inflector, jaxrs-cxf-cdi, jaxrs-spec, jaxrs-jersey, jaxrs-di, jaxrs-resteasy-eap, jaxrs-resteasy, micronaut, spring, nodejs-server, openapi, openapi-yaml, kotlin-client, kotlin-server, php, python, python-flask, r, ruby, scala, scala-akka-http-server, swift3, swift4, swift5, typescript-angular, typescript-axios, typescript-fetch, javascript]

Installation

Npm package for use with swagger-codegen-cli-3.0.34.jar

npm install -g swagger-nodegen-cli

Npm package for use with swagger-codegen-cli-2.4.4.jar

npm install -g [email protected]

Usage

Same as swagger-codegen-cli.jar without java -jar ... The main command is sc, swagger-codegen-cli or swagger-nodegen-cli (under Windows sc is in conflict with sc.exe)

usage: swagger-codegen-cli <command> [<args>]

usage: swagger-nodegen-cli <command> [<args>]

usage: sc <command> [<args>] (under windows sc is in conflicts with sc.exe)

Examples

Display help, extended help, version and available languages

# help, extended help
swagger-codegen-cli -h
swagger-codegen-cli generate -h

# Version
swagger-codegen-cli version

# Available languages
swagger-codegen-cli
swagger-codegen-cli langs

Display detailed generation config options for a specific language

swagger-codegen-cli config-help -l typescript-angular

Generate openapi.json (v3) from swagger.json (v2) or openapi.yaml (v3)

swagger-codegen-cli generate -l openapi -i <path/to/[swagger.json|openapi.yaml]> -o <out folder>

Generate openapi.yaml (v3) from swagger.json (v2) or openapi.json (v3)

swagger-codegen-cli generate -l openapi-yaml -i <path/to/[swagger|openapi].json> -o <out folder>

Generate a typescript-angular service from an Open API V2 (swagger)/V3 - JSON or YML file

Features

  • Generates an Angular service per defined swagger resource
  • Generates models with custom property name flavours: camelCase, PascalCase, snake_case ... (see swagger-codegen-cli config-help -l typescript-angular)
  • Base path injection with InjectionToken
swagger-codegen-cli generate -i swagger.json -l typescript-angular -o src/services
swagger-codegen-cli generate -i open-api.yml -l typescript-angular -o src/services

Integration into an Angular application


|-- angular-application
|-- src
|   |-- app
|   |   |-- app.component.html
|   |   |-- app.component.ts
|   |   |-- app.component.css
|   |   |-- app.module.ts
|   `-- services
|       |-- ...

./src/app/app.module.ts

import { NgModule } from '@angular/core';
import { HttpClientModule } from '@angular/common/http';
import { BrowserModule }  from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { ApiModule, BASE_PATH } from '../services';

@NgModule({
  imports: [
    BrowserModule,
    HttpClientModule,
    ApiModule
  ],
  declarations: [
    AppComponent
  ],
  providers: [
    { provide: BASE_PATH, useValue: 'http://localhost:10010' }
  ],
  bootstrap: [ AppComponent ]
})
export class AppModule { }

Generate a nodjs-server skelton from an Open API V2 (swagger)/V3 - JSON or YML file


swagger-codegen-cli generate -i swagger.json -l nodejs-server -o my-server
swagger-codegen-cli generate -i open-api.yml -l nodejs-server -o my-server

Links