microsoft / kiota

OpenAPI based HTTP Client code generator
https://aka.ms/kiota/docs
MIT License
2.84k stars 194 forks source link

Cannot get response deserialization to work with GS1 EPCIS standard open api. #4885

Closed yvdh closed 2 months ago

yvdh commented 2 months ago

What are you generating using Kiota, clients or plugins?

API Client/SDK

In what context or format are you using Kiota?

Nuget tool

Client library/SDK language

Csharp

Describe the bug

I am trying to generate an API client for an extensive standardised API, namely GS1 EPCIS (see https://ref.gs1.org/standards/epcis/artefacts for the open api in json format). I really like the way Kiota create a fluent API for the client (most other API generators create quite messy sets of endpoints). However, this API relies on the oneOf with schema construct for heterogenuous collections derived from a base class. Although I can perfectly call the API and requests seem to serialize properly as far as I can tell, the responses seem to choke on those heterogenuous collections.

Upon inspection the generator seem to use compositing instead of derivation. As stated in the docs on MSDN, this is by design. However, I can't seem any respons to deserialize with that pattern either (oneOf => allOf with discriminator). Also, it's probably not a good idea to modify an API spec that's standardized anyway ...

More specifically, I have problems with the 'EPCISEvent' collections, and the LDContext. Ask away if more details needed, I am a bit lost as to where to start ... Cheers

Expected behavior

Implement oneOf as per OpenAPi spec, not necessarily how it's been (mis)used to implement inheritance in the past.

How to reproduce

Generate client from open spec. Create query to existing server for a set of events (eventTypes/ObjectEvent/events/?MATCH_epc=urn:epc:id:sscc:*). The returned EPCISQueryDocument contains nulls in the LDContext and EventList properties.

Open API description file

https://ref.gs1.org/standards/epcis/openapi.json

Kiota Version

1.15

Latest Kiota version known to work for scenario above?(Not required)

No response

Known Workarounds

No response

Configuration

No response

Debug output

Click to expand log ``` ```

Other information

No response

baywet commented 2 months ago

Hi @yvdh Thanks for using kiota and for reaching out. Can you provide a sample response please?

I'm guessing that when you refer to the LD context not deserializing properly, you're referring to this schema?

"LDContext": {
                "description": "JSON-LD @context.",
                "anyOf": [
                    {
                        "type": "array",
                        "items": {
                            "anyOf": [
                                {
                                    "type": "string",
                                    "format": "uri"
                                },
                                {
                                    "type": "object"
                                }
                            ]
                        }
                    },
                    {
                        "type": "string",
                        "format": "uri"
                    },
                    {
                        "type": "object"
                    }
                ]
            }
microsoft-github-policy-service[bot] commented 2 months ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.