|
1 | 1 | # Generating API |
2 | 2 |
|
3 | | -To generate the API first download swagger-codegen () and build it. After its built, create an alias: |
4 | | -alias swagger-codegen='java -jar [/path/to/built/swagger-codegen]/swagger-codegen/modules/swagger-codegen-cli/target/swagger-codegen-cli.jar' |
| 3 | +To generate the API first download [swagger-codegen](https://github.com/swagger-api/swagger-codegen) and build it. After its built, create an alias: |
5 | 4 |
|
6 | | -To rebuild the JSON API spec due to YAML changes (required for docs UI to be accurate): `generate -i swagger.yaml -o ./generated-json -l swagger` |
| 5 | +`alias swagger-codegen='java -jar [/path/to/built/swagger-codegen]/swagger-codegen/modules/swagger-codegen-cli/target/swagger-codegen-cli.jar'` |
7 | 6 |
|
8 | | -To build the server stub (node): `swagger-codegen generate -i swagger.yaml -o ./server/generated-server -l nodejs-server` |
| 7 | +##Generating the JSON Spec |
| 8 | +Anytime the root swagger.yaml is modified the JSON spec should be updated and copied into |
| 9 | +`swagger-ui/dist/swagger-spec.js` as the value for the `swaggerSpec` var. Currently this is a manual process. |
9 | 10 |
|
10 | | -To build the client (typescript): `swagger-codegen generate -i swagger.yaml -o ./client/generated-client -l typescript-node` |
| 11 | +To regenerate the JSON API spec due to YAML changes (required for docs UI to be accurate): `generate -i swagger.yaml -o ./generated-json -l swagger`. |
| 12 | +The generated JSON can be deleted after its been copied to `swagger-spec.js`. |
11 | 13 |
|
12 | | -The API can be built for a number of other languages as well but you will need to manually port the business logic from the existing nodesjs-server \ |
13 | | -API to the languages of your choice. We encourage anyone who does this to submit a pull request to have their server API added to the official repo. |
| 14 | +##Generating Server Stubs |
| 15 | +You can contribute to the syscoin-api project by writing connectors for Syscoin in different languages. |
| 16 | +Swagger-codegen can greatly reduce the time it takes to write connectors in other languages by generating a server-api stub |
| 17 | +in the desired language. To generate the Server stub use the command below replacing LANGUAGE with one of the [supported SwaggerJS server values](https://github.com/swagger-api/swagger-codegen/wiki/Server-stub-generator-HOWTO). |
14 | 18 |
|
| 19 | +To build the server SDK stub: `swagger-codegen generate -i swagger.yaml -o ./server/generated-server -l LANGUAGE` |
| 20 | + |
| 21 | +We encourage anyone who does this to submit a pull request to have their server API added to the official repo. |
15 | 22 | Package your server API using folder names mirroring the swagger language name, ie: 'nodejs-server'. Client API's can also be submitted using the same \ |
16 | | - format. |
| 23 | + format. |
| 24 | + |
| 25 | +##Generating the Client SDK |
| 26 | +To quickly start communicating with an instance of the Syscoin API server simply generate a client-side SDK |
| 27 | +in your preferred language. To generate the Client SDK use the command below replacing LANGUAGE with one of |
| 28 | +the [supported SwaggerJS client values](https://generator.swagger.io/#!/clients/clientOptions). |
| 29 | + |
| 30 | +To build the client: `swagger-codegen generate -i swagger.yaml -o ./client/generated-client -l LANGUAGE` |
0 commit comments