Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Regenerate Client Against OCAPI Version 20.4#37

Merged
bendvc merged 21 commits intodevelopfrom
regenerate-20_4
Jul 21, 2020
Merged

Regenerate Client Against OCAPI Version 20.4#37
bendvc merged 21 commits intodevelopfrom
regenerate-20_4

Conversation

@bendvc
Copy link
Copy Markdown
Contributor

@bendvc bendvc commented Jul 21, 2020

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

  • Updated swagger.json file.
  • Added some lint rules so that we don't error out due to empty constructors of class properties.
  • Added transform-class-properties babel plugin to handle class properties (that is how the api's and models are generated, in the past we manually move those properties into the constructors)
  • Ran lint and copyright fixes.
  • Fixed rollup configuration to work with transform-class-properties
  • Various fixes with the generated code including, removing unused imports, removed imports with conflicting class names, fixed some file names, etc.
  • Updated change log.

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?

  • Clone repository
  • Run npm ci
  • Run npm run test // All tests should pass

Alternatively you can run the Scaffold by first:

  • Updating the commerce-integrations package json like this npm run lerna -- add commercecloud-ocapi-client@0.1.13-release-candidate.0 --scope=@mobify/commerce-integrations
  • Then running the pwa like this MOBIFY_CONNECTOR_NAME=sfcc npm run start

TODO

  • Before merging bump back the package version to 0.1.12 as the package bumping happens when merging into master.

Copy link
Copy Markdown
Contributor

@kevinxh kevinxh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@bendvc
Copy link
Copy Markdown
Contributor Author

bendvc commented Jul 21, 2020

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)

@bendvc bendvc merged commit 907afbe into develop Jul 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Development

Successfully merging this pull request may close these issues.

2 participants