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

ng-openapi-gen-cli

v1.0.1

Published

A CLI tool for openapi 3.0 codegen for Angular

Downloads

5

Readme

ng-openapi-gen-cli: CLI for ng-openapi-gen npm version

This project is a npm module that provides management operations of api services via ng-openapi-gen.

How to use it

In your project, run:

cd <your_angular_app_dir>
npm install ng-openapi-gen-cli --save-dev
node_modules/.bin/ng-openapi-gen-cli OPERATION -i PATH_TO_NG_OPENAPI_CLI_JSON -s SELECTION

Where:

  • PATH_TO_NG_OPENAPI_CLI_JSON is the relative path to the ng-openapi-cli JSON file.
  • OPERATION is the operation that should be executed. There are three operations permitted: generate, update and update-local.
  • SELECTION is an optional argument, that lets you execute operations on a selected service. If your selection contains more than one service, you have to provide the flag multiple times. For example: -s service1 -s service2

Please, run the ng-openapi-gen-cli with the --help argument to view all available command line arguments.

Supported operations

These are the currently supported operations:

  • generate: Generates the files of the local openapi descriptor via ng-openapi-gen.
  • update: Updates the local openapi descriptor with the latest remote one and generates the files of the local openapi descriptor via ng-openapi-gen.
  • local-update: Updates the local openapi descriptor with the latest local remote one and generates the files of the local openapi descriptor via ng-openapi-gen.

Configuration file

The api service configuration must be passed with a configuration file. The default configuration file name is ng-openapi-cli-gen.json, and should be placed on the root folder of your NodeJS project.

An accompanying JSON schema is also available, so the configuration file can be validated, and IDEs can autocomplete the file. If you have installed and saved the ng-openapi-gen-cli module in your node project, you can use a local copy of the JSON schema on ./node_modules/ng-openapi-gen-cli/ng-openapi-gen-cli-schema.json.

Configuration file reference

The supported properties in the JSON file are:

  • defaultLocalUrl: The (default) local url endpoint of the openapi descriptor. This is needed for comparing local and remote json files and for updating the local file.
  • defaultUrl: The (default) url endpoint of the openapi descriptor. This is needed for comparing local and remote json files and for updating the local file.
  • name: The name of the service. This is just needed for reference and does not affect anything else.
  • openapiGen: The relative location of the ng-openapi-gen configuration file, that describes how the files should be generated for the given service.

Configuration file example

The following is an example of a configuration file:

{
  "$schema": "./node_modules/ng-openapi-gen-cli/ng-openapi-gen-cli-schema.json",
  "configurations": [
    {
      "defaultLocalUrl": "http://localhost:8080",
      "defaultUrl": "http://url/to/openapi/v3/api-docs",
      "name": "auth",
      "openapiGen": "./path/to/ng-openapi-gen/file.json"
    }
  ]
}

Setting up a node script

Regardless if your Angular project was generated or is managed by Angular CLI, or you have started your project with some other seed (for example, using webpack directly), you can set up a scripts block.

To do so, create the ng-openapi-gen-cli.json configuration file and add the following scripts to your package.json:

{
  "scripts": {
    "openapi:generate": "ng-openapi-gen-cli generate -i ng-openapi-gen-cli.json",
    "openapi:update": "ng-openapi-gen-cli update -i ng-openapi-gen-cli.json",
    "openapi:update:local": "ng-openapi-gen-cli local-update -i ng-openapi-gen-cli.json"
  }
}