reapit / foundations

Foundations platform mono repo
57 stars 22 forks source link

Property status enumeration issue in OpenAPI specification #3566

Closed JonCognioDigital closed 3 years ago

JonCognioDigital commented 3 years ago

Describe the bug The typescript typings for Properties contain extra spaces. He's a copy and paste directly from the platform-schema.ts file...

sellingStatus?: ( | 'preAppraisal' | 'valuation' | 'paidValuation' | 'forSale ' | 'forSaleUnavailable' | 'underOffer' | 'underOfferUnavailable' | 'reserved' | 'exchanged ' | 'completed' | 'soldExternally' | 'withdrawn' )[]

forSale and exchanged have an extra space at the end. The same is true of some of the lettings statuses.

The problem I am having with this is I am making a call to get all properties that are for sale, but because I am not adding the extra space I can't compile my code because of a Typescript error. I'm also reporting it on the off chance that if your own code is using the same typings then it's possible the filtering for those statuses isn't working properly?

Specification

cbryanreapit commented 3 years ago

This appears to be down to the way that some of our enumerations are being generated in our OpenAPI specification. As demonstrated below:

image

To be reviewed.

willmcvay commented 3 years ago

FYI @jon64digital see Craig's comment above. When the swagger doc has been updated, the types are auto generated and will be published to NPM. Thanks for reporting and we'll get a new version out as soon as possible.

willmcvay commented 3 years ago

As a workaround, you should be able to take the interface and extend it to trim the whitespace eg

import {PropertyModel} from '@reapit/foundations-ts-definitions'

interface PropertyModelCleaned extends PropertyModel {
  sellingStatus?: (
    | 'preAppraisal'
    | 'valuation'
    | 'paidValuation'
    | 'forSale'
    | 'forSaleUnavailable'
    | 'underOffer'
    | 'underOfferUnavailable'
    | 'reserved'
    | 'exchanged'
    | 'completed'
    | 'soldExternally'
    | 'withdrawn'
    )[]
}
JonCognioDigital commented 3 years ago

Thanks. I actually hacked round it by adding a space and then trimming it but thanks. I'll get the new version from NPM at some point.