ebowman / api-first-hand

API-First bootstrapping tool for building RESTful web services from a Swagger/OpenAPI spec
MIT License
142 stars 22 forks source link

property name seems to have to match ref name #55

Closed alexec closed 7 years ago

alexec commented 7 years ago

This does not work:

      countryCode:
        "$ref": "#/definitions/countryCodes"
Caused by: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "countryCode" (class des.yaml.AddressType), not marked as ignorable (6 known properties: "countryCodes", "postalCode", "addressLine1", "addressLine2", "addressLine3", "addressLine4"])
 at [Source: [B@2717a928; line: 16, column: 10] (through reference chain: des.yaml.CreateCustomerSubscription["customerCreateOrExtend"]->des.yaml.CreateCustomerSubscriptionCustomerCreateOrExtend["businessAddressDetails"]->des.yaml.AddressType["countryCode"])

But removing the plural "s" does?

      countryCode:
        "$ref": "#/definitions/countryCode"
slavaschmidt commented 7 years ago

Seems like a bug

alexec commented 7 years ago

Workaround

Cannot have the field name different to the type. E.g. countryCode must have a definition named countryCode, not countryCodes.

Good:

"countryCode": "#/definitions/countryCode"

Bad:

"countryCode": "#/definitions/countries"
LappleApple commented 7 years ago

Hi @alexec, would you like to make a PR to address this bug?

slavaschmidt commented 7 years ago

Hi @alexec, would it be possible for you to provide a full failing specification? I've glossed over simple.pestore.api.yaml and found for example following snippet:

parameters:
        - name: pet
          in: body
          description: Pet to add to the store
          required: true
          schema:
            $ref: '#/definitions/newPet'

which confirms that name of the parameter does not need to be related to the name of the type.

alexec commented 7 years ago

Sorry - due to change in work, I'm afraid I won't have a chance to look at this. Feel free to close.