mobify / commercecloud-ocapi-client

Salesforce Commerce Cloud Open Commerce API (OCAPI) for Node and browsers 🛒
MIT License
69 stars 31 forks source link

Regenerate Client Against OCAPI Version 20.4 #37

Closed bendvc closed 4 years ago

bendvc commented 4 years ago

Description

This PR regenerates the client based on the latest release of Salesforce's OCAPI swagger definition (version 20.4). In an attempt to make this process more palatable for future version bumps, I have made changes to linking rules and compilation tools so we don't have to manually intervene in the future as much.

JIRA: WEB-2759

Changes

General Approach to Doing Upgrade

  1. Get latest swagger definition from this API explorer (https://api-explorer.commercecloud.salesforce.com/?url=https://demo-ocapi.demandware.net/s/-/dw/meta/v1/rest/meta/v99_9#!/rest/getRestByIDByID)
  2. Using v2.2.3 of swagger-codegen generate a new client with the following command 👉 swagger-codegen generate -c conf.json -i swagger.json -l javascript --model-package models -o new
  3. Copy over all the models from new/src/models folder and overwrite the existing ones.
  4. Do the same for the api's in the new/src/api folder. Also bring over the new index.js file and make sure that you update the named export to be the default export.
  5. Update the copyright headins running npm run copyright:fix
  6. Fix lint errors running npm run lint:fix You'll have to manually fix some errors mentioned above.
  7. There are 3 specific manual fixes you have to do. (ensure we are saving auth here, reverse argument order here, add fault import and export to index.js here )
  8. Update the docs by running npm run docs
  9. Release a release candidate and test in the commerce integrations via the mono repo

How to test this PR?

Alternatively you can run the Scaffold by first:

TODO

bendvc commented 4 years ago

NICE!! Would it make sense to add the generation process to README?

The process to regenerate isn't THAT straight forward. So I'd like to avoid that for now. I don't think there is going to be much work on this project in the future. But we we do decide to put more effort into it, then yes that is a good idea. (Note: I don't think salesforce themselves are going to be coming out with too many new versions of ocapi as their are going to be using their new offering)