Code Monkey home page Code Monkey logo

javascript-clients's Introduction

Javascript Clients

Auto generated Javascript clients for swagger API

Overview

This repository is set up as a monorepo for all API clients to use one configuration and release cycle. This repo is using NX as its monorepo manager and Github Actions for CI/CD as well as publishing packages to NPM.

Local development

We are using Java to install and build this generator. Please install Java and preferably Maven as well so you don't have any issues when building this new generator.

  • Once you have Java and Maven installed you can install dependencies by running npm install

  • When you have dependencies installed you can run build anytime you change something in the generator npm run build:generator

Creating a new client

Run npm run create-client and enter your new client name (e.g. entering notifications will generate notifications-client). All the necessary TS and NX config files will be created for you.

IMPORTANT! Ensure the SPEC URL in you generate:prod script in the package.json matches your spec correctly. Also, don't forget to update your packages's README with the correct install and usage information.

Generating and Building clients

From the root javascript-clients folder:

  • To generate all clients run npm run generate -- The command must be run with git origin set to the upstream repository (RedHatInsights/javascript-clients) - this way the correct docs and references are generated.
  • To build clients and generate their dist to be published run npm run build -- NX will only build packages when it detects that a change has been made to the client (otherwise it will reference the cache). After a client has been built, our builder (located in packages/build-utils) will move each client's dist into a top-level dist for publishing. Use npx nx run-many --skip-nx-cache -t build --exclude=@redhat-cloud-services/CLIENTNAME-client if you wish to build all clients regardless of whether or not a change has been made.

Custom Module Federation Generator

As the default, we use typescript-axios to generate a client based on their OpenAPI spec. In addition, we have a custom generator available for use built with module federation in mind which allows for treeshaking by webpack. This will create a new folder for each endpoint allowing consumers to import only the endpoints they are going to use without the need of importing the entire API. This generator should be a replacement for the regular typescript-axios generator. See below for an example script to use the new generator:

{
  "name": "@redhat-cloud-services/some-client-name",
  "version": "1.0.0",
  "scripts": {
    "generate": "TS_POST_PROCESS_FILE='../../postProcess.sh' openapi-generator-cli generate -i $SPEC --custom-generator=../../target/typescript-axios-webpack-module-federation-openapi-generator-1.0.0.jar -g typescript-axios-webpack-module-federation -o . --skip-validate-spec --enable-post-process-file"
  }
}

If you've previously used the typescript-axios generator you will also have to change the version of generator-cli.version in openapitool.json to at least 6.6.0.

javascript-clients's People

Contributors

aneelac22 avatar apinkert avatar astonlele avatar catastrophe-brandon avatar dependabot[bot] avatar fhlavac avatar florkbr avatar gkarat avatar hyperkid123 avatar jason-rh avatar jharting avatar jiridostal avatar josejulio avatar karelhala avatar lesamo avatar lgalis avatar mkholjuraev avatar nacho-bot avatar rvsia avatar tkasparek avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

javascript-clients's Issues

Versioning of packages doesn't follow the semantic versioning specification

Hello, I recently worked with one of the API client - @redhat-cloud-services/host-inventory-client and the Inventory application (which is a consumer of this client). While I was upgrading the client dependency version from 1.0.96 to 1.0.109, I found out that the application has got broken. Debugging the problem, I realized that the HostsApi's apiHostGetHostList function parameters were modified (specifically, the order has changed, and the wrong parameters were sent by the consumer app).

I managed to fix this and this is OK to have client interface changes, however, I would love to see such breaking changes documented and reflected with the help of versioning of the package. Just incrementing the patch version is not correct, because I would expect the increment of the major version if a broken change introduced to the interface.

Just for evidence and illustration, this is the commit that changed the function parameters: b9b6839#diff-a9f2cff91e34cf8e2a01709fba111c82cc0e22f1f5f3782607c7f789beb189aeR1907.

axios security issue

Hi,

We got a new CVE ticket about axios for our project (OCM):
https://issues.redhat.com/browse/OCMUI-1491

CVE-2023-45857 axios: exposure of confidential data stored in cookies
https://bugzilla.redhat.com/show_bug.cgi?id=2248979

An issue discovered in Axios 1.5.1 inadvertently reveals the confidential XSRF-TOKEN stored in cookies by including it in the HTTP header X-XSRF-TOKEN for every request made to any host allowing attackers to view sensitive information.

https://github.com/axios/axios/issues/6006
https://github.com/jeffbski/wait-on/pull/147

@redhat-cloud-services/rbac-client is on axios@^0.27.2

It's not clear if the reported issue was introduced with 1.5.1. Anyway, older versions of axios got their share of CVEs reported over time.

Do you think it could be possible to update it to latest?
Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.