Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENG-11977 Fix logic in getModel to recognize typeless object schemas #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

robcmills
Copy link
Collaborator

@robcmills robcmills commented Jan 3, 2023

Description

The api client generated from our openapi.json spec file (generated by the backend) had incomplete return types for some methods.
This was due to a bug in the getModel method, whereby if a schema definition passed in had no type property, but was in fact an object (had properties which implies an object), then it would "fall through" all the conditions and return an "empty" model. There was no condition to capture this edge case.

As far as I can tell, the type property is optional, according to the OpenAPI spec, and the properties attribute is used to describe only objects, so its presence allows you to safely assume an object type. This logic was added to the existing object predicate, and a unit test was added to assert it.

Test Plan

  • Ensure all of this repos "checks" still pass:
    • npm install
    • npm run build
    • npm run validate
    • npm run test
    • npm run eslint

Copy link

@mracette mracette left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! As mentioned in Slack, I think that we should look into submitting this change as a PR into the upstream library. It would potentially benefit others who are using this library and could reduce the long term maintenance costs that we are taking on by forking it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants