-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: allow forced rmf server version, add script to generate api-cl…
…ient openapi Signed-off-by: Teo Koon Peng <[email protected]>
- Loading branch information
Teo Koon Peng
committed
Apr 12, 2021
1 parent
bf4b808
commit 6f8d4a3
Showing
13 changed files
with
288 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import json | ||
import os | ||
|
||
from api_server.app import app | ||
|
||
here = os.path.realpath(os.path.dirname(__file__)) | ||
os.makedirs(f"{here}/build", exist_ok=True) | ||
with open(f"{here}/build/openapi.json", "w") as f: | ||
json.dump(app.openapi(), f) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
function usage() { | ||
echo "Usage: generate-models.sh" | ||
} | ||
|
||
cd $(dirname $0) | ||
|
||
source ../../scripts/version.sh | ||
|
||
expected_sha='cde6255246cf76b9e4c20e85968d36505930700f8adad68e76c0bc5a6721bfe5' | ||
|
||
if [[ ! -f '.bin/swagger-codegen-cli.jar' ]]; then | ||
wget https://repo1.maven.org/maven2/io/swagger/codegen/v3/swagger-codegen-cli/3.0.25/swagger-codegen-cli-3.0.25.jar -O .bin/swagger-codegen-cli.jar | ||
fi | ||
|
||
sha=$(sha256sum .bin/swagger-codegen-cli.jar | awk '{print $1}') | ||
|
||
if [[ $sha != $expected_sha ]]; then | ||
echo "ERR: .bin/swagger-codegen-cli.jar sha doesn't match" | ||
exit 1 | ||
fi | ||
|
||
swagger_ver=$(java -jar .bin/swagger-codegen-cli.jar version) | ||
java -jar .bin/swagger-codegen-cli.jar generate -i'build/openapi.json' -ltypescript-axios -olib/openapi | ||
# There is a bug with `ModelObject` type being missing, workaround it by adding a type to the generated models. | ||
echo 'export type ModelObject = Record<string, any>;' >> lib/openapi/models/index.ts | ||
|
||
rmf_server_ver=$(getVersion .) | ||
|
||
cat << EOF > lib/version.ts | ||
// THIS FILE IS GENERATED | ||
import { version as rmfModelVer } from 'rmf-models'; | ||
export const version = { | ||
rmfModels: rmfModelVer, | ||
rmfServer: '$rmf_server_ver', | ||
swaggerCodegen: '$swagger_ver', | ||
}; | ||
EOF | ||
|
||
../../node_modules/.bin/prettier -w lib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
/** | ||
* FastAPI | ||
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) | ||
* | ||
* OpenAPI spec version: 0.1.0 | ||
* | ||
* | ||
* NOTE: This class is auto generated by the swagger code generator program. | ||
* https://github.com/swagger-api/swagger-codegen.git | ||
* Do not edit the class manually. | ||
*/ | ||
import globalAxios, { AxiosPromise, AxiosInstance } from 'axios'; | ||
import { Configuration } from '../configuration'; | ||
// Some imports not used depending on template conditions | ||
// @ts-ignore | ||
import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from '../base'; | ||
import { BuildingMap } from '../models'; | ||
/** | ||
* BuildingApi - axios parameter creator | ||
* @export | ||
*/ | ||
export const BuildingApiAxiosParamCreator = function (configuration?: Configuration) { | ||
return { | ||
/** | ||
* | ||
* @summary Get Building Map | ||
* @param {*} [options] Override http request option. | ||
* @throws {RequiredError} | ||
*/ | ||
getBuildingMapBuildingMapGet: async (options: any = {}): Promise<RequestArgs> => { | ||
const localVarPath = `/building_map`; | ||
// use dummy base URL string because the URL constructor only accepts absolute URLs. | ||
const localVarUrlObj = new URL(localVarPath, 'https://example.com'); | ||
let baseOptions; | ||
if (configuration) { | ||
baseOptions = configuration.baseOptions; | ||
} | ||
const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options }; | ||
const localVarHeaderParameter = {} as any; | ||
const localVarQueryParameter = {} as any; | ||
|
||
const query = new URLSearchParams(localVarUrlObj.search); | ||
for (const key in localVarQueryParameter) { | ||
query.set(key, localVarQueryParameter[key]); | ||
} | ||
for (const key in options.query) { | ||
query.set(key, options.query[key]); | ||
} | ||
localVarUrlObj.search = new URLSearchParams(query).toString(); | ||
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; | ||
localVarRequestOptions.headers = { | ||
...localVarHeaderParameter, | ||
...headersFromBaseOptions, | ||
...options.headers, | ||
}; | ||
|
||
return { | ||
url: localVarUrlObj.pathname + localVarUrlObj.search + localVarUrlObj.hash, | ||
options: localVarRequestOptions, | ||
}; | ||
}, | ||
}; | ||
}; | ||
|
||
/** | ||
* BuildingApi - functional programming interface | ||
* @export | ||
*/ | ||
export const BuildingApiFp = function (configuration?: Configuration) { | ||
return { | ||
/** | ||
* | ||
* @summary Get Building Map | ||
* @param {*} [options] Override http request option. | ||
* @throws {RequiredError} | ||
*/ | ||
async getBuildingMapBuildingMapGet( | ||
options?: any, | ||
): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<BuildingMap>> { | ||
const localVarAxiosArgs = await BuildingApiAxiosParamCreator( | ||
configuration, | ||
).getBuildingMapBuildingMapGet(options); | ||
return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { | ||
const axiosRequestArgs = { | ||
...localVarAxiosArgs.options, | ||
url: basePath + localVarAxiosArgs.url, | ||
}; | ||
return axios.request(axiosRequestArgs); | ||
}; | ||
}, | ||
}; | ||
}; | ||
|
||
/** | ||
* BuildingApi - factory interface | ||
* @export | ||
*/ | ||
export const BuildingApiFactory = function ( | ||
configuration?: Configuration, | ||
basePath?: string, | ||
axios?: AxiosInstance, | ||
) { | ||
return { | ||
/** | ||
* | ||
* @summary Get Building Map | ||
* @param {*} [options] Override http request option. | ||
* @throws {RequiredError} | ||
*/ | ||
getBuildingMapBuildingMapGet(options?: any): AxiosPromise<BuildingMap> { | ||
return BuildingApiFp(configuration) | ||
.getBuildingMapBuildingMapGet(options) | ||
.then((request) => request(axios, basePath)); | ||
}, | ||
}; | ||
}; | ||
|
||
/** | ||
* BuildingApi - object-oriented interface | ||
* @export | ||
* @class BuildingApi | ||
* @extends {BaseAPI} | ||
*/ | ||
export class BuildingApi extends BaseAPI { | ||
/** | ||
* | ||
* @summary Get Building Map | ||
* @param {*} [options] Override http request option. | ||
* @throws {RequiredError} | ||
* @memberof BuildingApi | ||
*/ | ||
public getBuildingMapBuildingMapGet(options?: any) { | ||
return BuildingApiFp(this.configuration) | ||
.getBuildingMapBuildingMapGet(options) | ||
.then((request) => request(this.axios, this.basePath)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// THIS FILE IS GENERATED | ||
import { version as rmfModelVer } from 'rmf-models'; | ||
|
||
export const version = { | ||
rmfModels: rmfModelVer, | ||
rmfServer: 'bf4b8085153d73ab5094504e34fbac0d1fbeb6f4', | ||
swaggerCodegen: '3.0.25', | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.