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

[bug : requestIPReservation] Response structure matches multiple oneOf schemas #30

Open
VamshikShetty opened this issue Aug 2, 2022 · 2 comments

Comments

@VamshikShetty
Copy link
Contributor

In case API : POST /projects/{id}/ips i.e. requestIPReservation function response structure is oneOf response between IPReservation and VrfIpReservation. Response provided by server when we try to reserve public IPv4 throws following error :

Caused by: java.io.IOException: Failed deserialization for RequestIPReservation201Response: 2 classes match result, expected 1. Detailed failure message for oneOf schemas: []. JSON: {"id":"9abf77b3-705f-4d49-84fd-f8f638ec7eb0","address_family":4,"netmask":"255.255.255.252","created_at":"2022-08-02T15:51:54Z","details":null,"tags":[],"public":true,"cidr":30,"management":false,"manageable":true,"enabled":true,"global_ip":false,"customdata":{},"addon":true,"bill":true,"state":"created","project":{"href":"/metal/v1/projects/d52cf346-cd0e-4d4f-828a-29e4c5e60f72"},"project_lite":{"href":"/metal/v1/projects/d52cf346-cd0e-4d4f-828a-29e4c5e60f72"},"assignments":[],"metal_gateway":null,"requested_by":{"href":"/metal/v1/users/d5c43ee4-676d-4098-b769-23c03626f59d"},"network":"147.28.154.156","address":"147.28.154.158","gateway":"147.28.154.157","available":"/metal/v1/ips/9abf77b3-705f-4d49-84fd-f8f638ec7eb0/available","href":"/metal/v1/ips/9abf77b3-705f-4d49-84fd-f8f638ec7eb0","facility":null,"metro":{"id":"d3d6b29f-042d-43b7-b3ce-0bf53d5754ca","name":"Dallas","code":"da","country":"US"},"type":"public_ipv4"}
        at com.equinix.openapi.metal.v1.model.RequestIPReservation201Response$CustomTypeAdapterFactory$1.read(RequestIPReservation201Response.java:154)
        at com.equinix.openapi.metal.v1.model.RequestIPReservation201Response$CustomTypeAdapterFactory$1.read(RequestIPReservation201Response.java:88)
        at com.google.gson.TypeAdapter$1.read(TypeAdapter.java:199)

JSON response is valid against both schema i.e.IPReservation and VrfIpReservation. In case of VrfIpReservation response structure contains "vrf" param which is not marked required hence above mentioned exception occurs.

Possible fix, VrfIpReservation should be update to have required param :

      "VrfIpReservation": {
         "properties": {
           "address_family": {
             "type": "integer"
           },
           "cidr": {
             "type": "integer"
           },
           "created_at": {
             "format": "date-time",
             "type": "string"
           },
           "created_by": {
             "$ref": "#/components/schemas/Href"
           },
           "details": {
             "type": "string"
           },
           "href": {
             "type": "string"
           },
           "id": {
             "format": "uuid",
             "type": "string"
           },
           "metal_gateway": {
             "$ref": "#/components/schemas/MetalGatewayLite"
           },
           "netmask": {
             "type": "string"
           },
           "network": {
             "type": "string"
           },
           "project": {
             "$ref": "#/components/schemas/Project"
           },
           "state": {
             "type": "string"
           },
           "tags": {
             "items": {
               "type": "string"
             },
             "type": "array"
           },
           "type": {
             "type": "string",
             "example": "vrf"
           },
           "vrf": {
             "$ref": "#/components/schemas/Vrf"
           }
         },
         "required": [
          "vrf"
         ],
         "type": "object"
       },
@VamshikShetty
Copy link
Contributor Author

Bug 2:
Response structure schema exists inline in spec hence generates following model RequestIPReservation201Response to wrap over oneOf over IPReservation and VrfIpReservation.

@rinzler-17
Copy link
Contributor

Related issue post #31 when parsing response after requesting a vrf ip reservation.

Error snippet:
com.google.gson.JsonSyntaxException: java.io.IOException: Failed deserialization for RequestIPReservation201Response: 2 classes match result, expected 1.

Cause: when requesting a vrf IP reservation, Json validation for response containing vrf field succeeds for IPReservation schema as well since additionalProperties is enabled in the spec configuration.

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

No branches or pull requests

2 participants