What are the Slack Archives?

It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.

Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..

Hi, I'm trying to create openapi java clients for the spryker glue api using the openapi generator (

UPDV9V3ST
UPDV9V3ST Posts: 21 🧑🏻‍🚀 - Cadet
edited November 2019 in Help

Hi, I'm trying to create openapi java clients for the spryker glue api using the openapi generator (https://openapi-generator.tech/). It works so far and I can access the glue API with Java. But it seems that there is a mismatch in the schema for getting carts. The swagger API specifies relationships within cart/data like this:

"relationships": {
      "concrete-products": [
        {
          "id": "string",
          "type": "string"
        }
      ]
    }

But when I use postman to test the cart API, I get for example this:

"relationships": {
            "items": {
                "data": [
                    {
                        "type": "items",
                        "id": "5077365"
                    },
                    {
                        "type": "items",
                        "id": "5580599"
                    }
                ]
            }
        }       

Therefore my java client gets an empty relationships object, because "concrete-products" does not match "items/data". Does anybody know why "concrete-products" is mapped to "items/data"?

Comments

  • Eugenia Poidenko
    Eugenia Poidenko Sprykee Posts: 145 🧑🏻‍🚀 - Cadet
    edited November 2019

    Hi Matthias.

    It looks like the generated documentation is wrong about the carts resource being related to concrete-products.

    I will open a bug in core to fix this in the generator tool.

    What the relationships of the carts should really look like is:

    RestCartsRelationships:
        properties:
            cart-permission-groups:
                items:
                    $ref: '#/components/schemas/RestRelationships'
            shared-carts:
                items:
                    $ref: '#/components/schemas/RestRelationships'
            items:
                items:
                    $ref: '#/components/schemas/RestRelationships'
    

    then the items should get the concrete-products relationship (the whole schema for the items is missing, but once fixed) should look like this:

    RestItemsResponse:
        properties:
            data:
                $ref: '#/components/schemas/RestItemsResponseData'
            links:
                $ref: '#/components/schemas/RestLinks'
    RestItemsResponseData:
        properties:
            type:
                type: string
            id:
                type: string
            attributes:
                $ref: '#/components/schemas/RestItemsAttributes'
            links:
                $ref: '#/components/schemas/RestLinks'
            relationships:
                $ref: '#/components/schemas/RestItemsRelationships'
    RestItemsAttributes:
        properties:
            sku:
                type: string
            quantity:
                type: number
            groupKey:
                type: string
            abstractSku:
                type: string
            amount:
                type: number
            calculations:
                $ref: '#/components/schemas/RestCartItemCalculations'
    RestCartItemCalculations:
        properties:
            unitPrice:
                type: number
            sumPrice:
                type: number
            taxRate:
                type: number
            unitNetPrice:
                type: number
            sumNetPrice:
                type: number
            unitGrossPrice:
                type: number
            sumGrossPrice:
                type: number
            unitTaxAmountFullAggregation:
                type: number
            sumTaxAmountFullAggregation:
                type: number
            sumSubtotalAggregation:
                type: number
            unitSubtotalAggregation:
                type: number
            unitProductOptionPriceAggregation:
                type: number
            sumProductOptionPriceAggregation:
                type: number
            unitDiscountAmountAggregation:
                type: number
            sumDiscountAmountAggregation:
                type: number
            unitDiscountAmountFullAggregation:
                type: number
            sumDiscountAmountFullAggregation:
                type: number
            unitPriceToPayAggregation:
                type: number
            sumPriceToPayAggregation:
                type: number
    RestItemsRelationships:
        properties:
            concrete-products:
                items:
                    $ref: '#/components/schemas/RestRelationships'
    

    Same would apply for guest-carts resource.

  • UPDV9V3ST
    UPDV9V3ST Posts: 21 🧑🏻‍🚀 - Cadet

    Thanks a lot for your quick answer!

  • UPDV9V3ST
    UPDV9V3ST Posts: 21 🧑🏻‍🚀 - Cadet
    edited December 2019

    I just found another bug of the same type. This time it's the getCustomers API. The data object contains something like this

    "relationships": {
                "addresses": {
                    "data": [
                        {
                            "type": "addresses",
                            "id": "31bb0ae4-ea88-5a7d-b580-90b12b1ba6c2"
                        }
                    ]
                }
            }
    

    But the specification says this:

    "relationships": {
          "addresses": [
            {
              "id": "string",
              "type": "string"
            }
          ],
    

    This breaks any openapi/swagger generated clients (again).
    My guess is that there are more of these bugs in the glue API....

  • Eugenia Poidenko
    Eugenia Poidenko Sprykee Posts: 145 🧑🏻‍🚀 - Cadet

    Another bug created. Thank you for your feedback.