Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
typescript-fetch-client/*
openapi-generator.jar
swagger-codegen-cli.jar
.idea/
*.iml
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# fulfillmenttools-api-reference
# fulfillmenttools API Reference

Public api assets for the fulfillmenttools platform API
This repository contains the public api assets for the fulfillmenttools platform API and instructions on how to generate API clients in various programming languages.

- [Open API Specification](api.swagger.yaml)
- [Technical Documentation](https://docs.fulfillmenttools.com)
- [API Documentation](https://fulfillmenttools.github.io/fulfillmenttools-api-reference-ui)
- [Technical Documentation](https://docs.fulfillmenttools.com)

# Generating API Clients from the Open API Specification

## typescript

## kotlin

## java

## python

16 changes: 5 additions & 11 deletions api-ctl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,27 @@ apiVersion=$2

apiUrl="https://raw.githubusercontent.com/fulfillmenttools/fulfillmenttools-api-reference/${apiVersion}/api.swagger.yaml"

swaggerCodeGen="https://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/2.4.18/swagger-codegen-cli-2.4.18.jar"
openapigenerator="https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.14.0/openapi-generator-cli-7.14.0.jar"


printUsage() {
printf "usage:\n"
printf "$0 download <apiVersion: git-hash-or-branchname> \t - downloads the api yaml file with given api version\n"
printf "$0 generate <apiVersion: git-hash-or-branchname> \t - generates typescript code for the api with the given api version\n"
printf "$0 convertToV3 <apiVersion: git-hash-or-branchname> \t - converts / the api (v2) to open API v3 format\n"
}

downloadApi() {
echo "download ${apiVersion}"
wget -N -nv -P "${SCRIPTDIR}" "${apiUrl}"
}

convertToV3() {
echo "converting the swagger v2 API with version: ${apiVersion} to Open API v3 format"
wget -nv -P "${SCRIPTDIR}" https://converter.swagger.io/api/convert?url="${apiUrl}" -O openapiv3.yaml
}

generate() {
echo "generate code for version ${apiVersion}"
wget -N -nv -P "${SCRIPTDIR}" "${swaggerCodeGen}" -O "${SCRIPTDIR}/swagger-codegen-cli.jar"
wget -N -nv -P "${SCRIPTDIR}" "${openapigenerator}" -O "${SCRIPTDIR}/openapi-generator.jar"
mkdir -p typescript-fetch-client
downloadApi
java -jar swagger-codegen-cli.jar generate -i api.swagger.yaml -l typescript-fetch -o ./typescript-fetch-client
cd typescript-fetch-client
java -jar "${SCRIPTDIR}/openapi-generator.jar" generate -g typescript-fetch -i "${SCRIPTDIR}/api.swagger.yaml" -o ./typescript-fetch-client --verbose
cd typescript-fetch-client
grep -n -A 64 "import \* as url" api.ts | sed -n 's/^\([0-9]\{1,\}\).*/\1d/p' | sed -f - api.ts > api.tmp
grep -n -A 10000 -B 4 "export const " api.tmp | sed -n 's/^\([0-9]\{1,\}\).*/\1d/p' | sed -f - api.tmp > api2.tmp
tail -n +2 api2.tmp > api.ts
Expand All @@ -48,7 +43,6 @@ main() {
case ${command} in
"download") downloadApi ;;
"generate") generate ;;
"convertToV3") convertToV3 ;;
*) printUsage; exit 0 ;;
esac
}
Expand Down