diff --git a/tools/generate.sh b/tools/generate.sh new file mode 100755 index 0000000..cfc0802 --- /dev/null +++ b/tools/generate.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +generatorCliImage=openapitools/openapi-generator-cli:v7.1.0 + +scriptDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +parentDir="$(dirname "$scriptDir")" + + +docker run --rm -v ${scriptDir}:/local ${generatorCliImage} validate -i /local/openapi.yaml --recommend +if [ $? -ne 0 ]; then + echo "openapi.yaml is not valid" + exit 1 +fi + +docker run --rm -v ${parentDir}:/vcell \ +${generatorCliImage} generate \ + -g python \ + -i /vcell/tools/openapi.yaml \ + -o /vcell \ + -c /vcell/tools/python-config.yaml diff --git a/tools/openapi.yaml b/tools/openapi.yaml new file mode 100644 index 0000000..ac83faf --- /dev/null +++ b/tools/openapi.yaml @@ -0,0 +1,541 @@ +--- +openapi: 3.0.3 +info: + title: VCell API + description: VCell API + termsOfService: Your terms of service here + contact: + name: VCell API Support + url: http://exampleurl.com/contact + email: vcell_support@uchc.com + license: + name: MIT + url: http://opensource.org/licenses/MIT + version: 1.0.1 +servers: +- url: https://vcellapi-test.cam.uchc.edu +paths: + /api/v1/admin/usage: + get: + tags: + - Admin Resource + summary: Get usage summary + operationId: getUsage + responses: + "200": + description: The PDF report + content: + application/pdf: + schema: + format: binary + type: string + "401": + description: Not Authorized + "403": + description: Not Allowed + security: + - openId: + - admin + /api/v1/bioModel/upload_bioModel: + post: + tags: + - Bio Model Resource + summary: Upload the BioModel to VCell database. Returns BioModel ID. + operationId: uploadBioModel + requestBody: + content: + text/xml: + schema: + type: string + responses: + "200": + description: OK + content: + text/plain: + schema: + type: string + /api/v1/bioModel/{bioModelID}: + get: + tags: + - Bio Model Resource + summary: Get BioModel information in JSON format by ID. + operationId: getBiomodelById + parameters: + - name: bioModelID + in: path + required: true + schema: + type: string + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/BioModel' + delete: + tags: + - Bio Model Resource + summary: Delete the BioModel from VCell's database. + operationId: deleteBioModel + parameters: + - name: bioModelID + in: path + required: true + schema: + type: string + responses: + "204": + description: No Content + /api/v1/helloworld: + get: + tags: + - Hello World + summary: Get hello world message. + operationId: getHelloWorld + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/HelloWorldMessage' + /api/v1/publications: + get: + tags: + - Publication Resource + summary: Get all publications + operationId: getPublications + responses: + "200": + description: OK + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Publication' + put: + tags: + - Publication Resource + summary: Create publication + operationId: updatePublication + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Publication' + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/Publication' + "401": + description: Not Authorized + "403": + description: Not Allowed + security: + - openId: + - curator + post: + tags: + - Publication Resource + summary: Create publication + operationId: createPublication + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Publication' + responses: + "200": + description: OK + content: + application/json: + schema: + format: int64 + type: integer + "401": + description: Not Authorized + "403": + description: Not Allowed + security: + - openId: + - curator + /api/v1/publications/{id}: + get: + tags: + - Publication Resource + summary: Get publication by ID + operationId: getPublicationById + parameters: + - name: id + in: path + required: true + schema: + format: int64 + type: integer + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/Publication' + delete: + tags: + - Publication Resource + summary: Delete publication + operationId: deletePublication + parameters: + - name: id + in: path + required: true + schema: + format: int64 + type: integer + responses: + "204": + description: No Content + "401": + description: Not Authorized + "403": + description: Not Allowed + security: + - openId: + - curator + /api/v1/users/bearerToken: + post: + tags: + - Users Resource + summary: Get token for legacy API + operationId: getLegacyApiToken + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/AccesTokenRepresentationRecord' + /api/v1/users/forgotLegacyPassword: + post: + tags: + - Users Resource + summary: "The end user has forgotten the legacy password they used for VCell,\ + \ so they will be emailed it." + operationId: forgotLegacyPassword + parameters: + - name: userID + in: query + schema: + type: string + responses: + "200": + description: Legacy password sent in email + "401": + description: Need to login to Auth0 + "500": + description: Internal Error + /api/v1/users/mapUser: + post: + tags: + - Users Resource + summary: map vcell user + operationId: mapUser + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/UserLoginInfoForMapping' + responses: + "200": + description: OK + content: + text/plain: + schema: + type: boolean + "401": + description: Not Authorized + "403": + description: Not Allowed + security: + - openId: + - user + /api/v1/users/mappedUser: + get: + tags: + - Users Resource + summary: Get mapped VCell identity + operationId: getMappedUser + responses: + "200": + description: "Successful, returning the identity" + content: + application/json: + schema: + $ref: '#/components/schemas/UserIdentityJSONSafe' + "404": + description: Identity not found + "401": + description: Not Authorized + "403": + description: Not Allowed + security: + - openId: + - user + /api/v1/users/me: + get: + tags: + - Users Resource + summary: Get current user + operationId: getMe + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/Identity' + /api/v1/users/newUser: + post: + tags: + - Users Resource + summary: create vcell user + operationId: mapNewUser + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/UserRegistrationInfo' + responses: + "200": + description: "Successful, returning the identity" + "409": + description: "VCell Identity not mapped, userid already exists" + "401": + description: Not Authorized + "403": + description: Not Allowed + security: + - openId: + - user + /api/v1/users/unmapUser/{userName}: + put: + tags: + - Users Resource + summary: remove vcell identity mapping + operationId: unmapUser + parameters: + - name: userName + in: path + required: true + schema: + type: string + responses: + "200": + description: OK + content: + application/json: + schema: + type: boolean + "401": + description: Not Authorized + "403": + description: Not Allowed + security: + - openId: + - user +components: + schemas: + AccesTokenRepresentationRecord: + type: object + properties: + token: + type: string + creationDateSeconds: + format: int64 + type: integer + expireDateSeconds: + format: int64 + type: integer + userId: + type: string + userKey: + type: string + Application: + type: object + BioModel: + type: object + properties: + bmKey: + type: string + name: + type: string + privacy: + format: int32 + type: integer + groupUsers: + type: array + items: + type: string + savedDate: + format: int64 + type: integer + annot: + type: string + branchID: + type: string + physModelKey: + type: string + ownerName: + type: string + ownerKey: + type: string + simulations: + type: array + items: + $ref: '#/components/schemas/Simulation' + applications: + type: array + items: + $ref: '#/components/schemas/Application' + BiomodelRef: + type: object + properties: + bmKey: + format: int64 + type: integer + name: + type: string + ownerName: + type: string + ownerKey: + format: int64 + type: integer + versionFlag: + format: int32 + type: integer + Date: + format: date + type: string + example: 2022-03-10 + HelloWorldMessage: + type: object + properties: + message: + type: string + Identity: + type: object + properties: + principal_name: + type: string + roles: + type: array + items: + type: string + attributes: + type: array + items: + type: string + credentials: + type: array + items: + type: string + MathmodelRef: + type: object + properties: + mmKey: + format: int64 + type: integer + name: + type: string + ownerName: + type: string + ownerKey: + format: int64 + type: integer + versionFlag: + format: int32 + type: integer + Publication: + type: object + properties: + pubKey: + format: int64 + type: integer + title: + type: string + authors: + type: array + items: + type: string + year: + format: int32 + type: integer + citation: + type: string + pubmedid: + type: string + doi: + type: string + endnoteid: + format: int32 + type: integer + url: + type: string + wittid: + format: int32 + type: integer + biomodelRefs: + type: array + items: + $ref: '#/components/schemas/BiomodelRef' + mathmodelRefs: + type: array + items: + $ref: '#/components/schemas/MathmodelRef' + date: + $ref: '#/components/schemas/Date' + Simulation: + type: object + properties: + name: + type: string + UserIdentityJSONSafe: + type: object + properties: + userName: + type: string + id: + type: number + subject: + type: string + insertDate: + type: string + UserLoginInfoForMapping: + type: object + properties: + userID: + type: string + password: + type: string + UserRegistrationInfo: + type: object + properties: + userID: + type: string + title: + type: string + organization: + type: string + country: + type: string + emailNotification: + type: boolean + securitySchemes: + openId: + type: openIdConnect + description: Authentication + openIdConnectUrl: https://dev-dzhx7i2db3x3kkvq.us.auth0.com/.well-known/openid-configuration diff --git a/tools/python-config.yaml b/tools/python-config.yaml new file mode 100644 index 0000000..1867c99 --- /dev/null +++ b/tools/python-config.yaml @@ -0,0 +1,44 @@ +# configuration for openapi CLI to generate Python client +# see https://openapi-generator.tech/docs/customization/ +# + +globalProperties: + # config options specific to the openapi-generator CLI + # see https://openapi-generator.tech/docs/customization/ + debugOpenAPI: false + debugModels: false + debugOperations: false + debugSupportingFiles: false + generateAliasAsModel: false + org.openapitools.codegen.utils.oncelogger.enabled: false + +additionalProperties: + # config options specific to the java generator + # see https://openapi-generator.tech/docs/generators/python/ + + # library template (sub-template) to use: asyncio, tornado (deprecated), urllib3 (Default: urllib3) + library: urllib3 + # date format for query parameters (Default: %Y-%m-%d) + dateFormat: "%Y-%m-%d" + # date-time format for query parameters (Default: %Y-%m-%dT%H:%M:%S%z) + dateTimeFormat: "%Y-%m-%dT%H:%M:%S%z" + # disallowAdditionalPropertiesIfNotPresent: true # default, but not compliant with OAS and JSON schema specifications + disallowAdditionalPropertiesIfNotPresent: true + # Specifies that only a library source code is to be generated. (Default: false) + generateSourceCodeOnly: false + # Hides the generation timestamp when files are generated. (Default: true) + hideGenerationTimestamp: true + # Map number to Union[StrictFloat, StrictInt], StrictStr or float. (Default: Union[StrictFloat, StrictInt]) + mapNumberTo: "Union[StrictFloat, StrictInt]" + # python package name (convention: snake_case). (Default: openapi_client) + packageName: vcell_api_client + # python package url. + packageUrl: https://github.com/virtualcell/vcell-api-client.git + # python package version. (Default: 0.1.0) + packageVersion: 0.1.0 + # python project name in setup.py (e.g. petstore-api). + projectName: vcell-api-client + # Set the recursion limit. If not set, use the system default value. + # recursionLimit: + # Use the discriminator's mapping in oneOf to speed up the model lookup. IMPORTANT: Validation (e.g. one and only one match in oneOf's schemas) will be skipped. (Default: false) + useOneOfDiscriminatorLookup: false