Sage-Bionetworks / sage-monorepo

Where OpenChallenges, Schematic, and other Sage open source apps are built
https://sage-bionetworks.github.io/sage-monorepo/
Apache License 2.0
21 stars 12 forks source link

feat(model-ad): explore Express API server #2714

Closed tschaffter closed 1 week ago

tschaffter commented 2 weeks ago

[!IMPORTANT]
Do not merge this until #2705 is merged.

[!NOTE]
This PR is for the sake of exploring an Express server generated by the OpenAPI Generator. The preferred approach to quickly migrate MODEL-AD REST API to this repo would be to copy the existing MODEL-AD Express server code as is to the project model-ad-api. If the MODEL-AD team decides to adopt specification-first development for this API, then I would recommend selecting one of the two languages and frameworks already used in this repo to align and speedup backend development, namely Java-Spring (e.g., openchallenges-challenge-service) or Python-Flask (schematic-api). @JessterB @hallieswan @sagely1

Description

This PR explores the Express server generated by the OpenAPI Generator (MODEL-AD currently uses an Express server).

References

Preview

Generate the API server stub

nx run model-ad-api:generate

Run the API server

nx serve model-ad-api

Access list of genes

The API includes a single endpoint to get a list of genes, which should return an empty array at this point.

$ curl -X GET -H "Content-type: application/json" \
    -H "Accept: application/json" \
    "http://localhost:8080/v1/genes" | jq .

{
  "message": "request should have required property 'headers'",
  "errors": [
    {
      "path": ".headers",
      "message": "should have required property 'headers'",
      "errorCode": "required.openapi.validation"
    }
  ]
}

[!NOTE]
A quick search online shows that upgrading express-openapi-validator from v3 to v4 solved this issue in some cases. I tried to simply upgrade to ^4.0.0 and ^5.0.0 but without success (server fails to start).

tschaffter commented 1 week ago

We are using the Spring-Boot implementation added in #2716 for our tutorial series.