For a new web project, I am seeking to develop a Swagger (OpenAPI) API that can be utilized by both the backend server (Go) and the frontend (Aurelia-CLI + TypeScript).
The swagger-codegen
tool provides various client generators including:
- typescript-angular
- typescript-angular2
- typescript-node
- typescript-fetch
In this particular case, only typescript-fetch
is applicable. To generate the client from a swagger.yml
, the following command is used:
swagger-codegen generate -i swagger.yml -l typescript-fetch -o api
This generates a project folder which can be viewed in the Swagger repository.
The question now arises on how to integrate this into an Aurelia project.
After running npm install
, a transpiled api.js
file (along with api.d.ts
) was generated. However, the next steps are unclear.
1) Where should the project folder be placed?
- src/api
-
node-modules/<fake-module-name>
- elsewhere
2) How can Aurelia be informed about the 'module' within the aurelia.json
configuration file?
- "<fake-module-name>"
-
"{
"name": "<fake-module-name>",
"path": "../node_modules/<fake-module-name>dist",
"main": "api"
}
- another method
The main issue being encountered is that despite Aurelia.json recognizing the API within the module, the dependencies within the module are causing the build process (au run --watch
) to halt as they are being searched for in the front-end's src
directory.
Any assistance in resolving this matter would be greatly appreciated.
P.S. It seems likely that importing the API module's dependencies and their subsequent dependencies into the aurelia.json file may be required...