Generators for REST-API in the portal-api
project. Note, on Windows, you must run this in Windows Subsustem for Linux
It's best to run this on a clean local repo to be able to see the changes.
# switch to portal-api folder
cd /mnt/c/code/portal-api
# generate the objects used in the API by parsing the Swagger
npm run definitions
# run the generation, it will start to prompt
npm run msapi
- MemberSuite Module? select the module for the new API
- Events Endpoint? for now, always select
CREATE NEW
- Endpoint Name (will live under events)? is the arbitrary name of the new endpoint, in caMel case.
- Method? select the HTTP method
- Relative route? enter the route, or take the default if ok
- Helper name? usually the default will be ok.
- What type to return? select the type from a list. If you don't see it make sure the API in C# is decorated with
SwaggerResponse
If the helper method is GetAvailableCapacity
, do the following:
- Edit
helper.model.ts
to import the REST return value, and the URL mapping to it - Edit
getAvailableCapacity.ts
and remove the TODOs - Edit
getAvailableCapacity.data.ts
to create sample data for tests that will look like the object ingetAvailableCapacity.d.ts
- Add test(s) to the appropriate
*.spec.ts
file
The easiest way to debug it, is to edit .\node_modules\generator-msapi\app\index.js
for testing, then manually merge changes into this repo.