-
Notifications
You must be signed in to change notification settings - Fork 228
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
OpenApi AnyOf with odata functions/actions generate invalid return types #990
Comments
Thanks for reporting that @andrueastman . Now that I'm re-reading the issue, it looks like it could be caused by the nullable property, which doesn't seem to be part of the original schema definition (i.e. upload session doesn't have nullable set). With all that being said, I'm wondering what nullable "means" in our context, if we followed the strict definition, our models should be structs unless marked as nullable. But that'd be an issue in a lot of languages for inheritance (and since all entities inherit from Entity...) Here is what we could do:
if solution 3 feels like a hack, I'm hesitant between 1 & 2 and I'd like @darrelmiller input with regards to what's the right thing to do here? |
Update: from my investigation (see linked issue in previous comment) the behavior of the conversion library seems to be conforming to the OpenAPI and OData specifications. I think the only question for @darrelmiller is: how should we handle nullable and non-nullable properties/schemas in Kiota? |
Sooo much to unpack. JSON Schema allows schemas like say a property value can be either an object or null: {
"type": [ "object", null ]
} OpenAPI prior to 3.1 does not allow JSON Schemas that look like this. This case is a special case where the schema is being used to define the entire response body. I believe in this case the nullable keyword is indicating that the payload maybe empty. Not really null. Certainly not a payload that has the characters
You can't have a 200 response with a content-type of |
but what about a property on upload session? (that'd be a nullable complex type) |
@baywet Go squish this to return an UploadSession and not CreateUploadSessionResponse
|
- fixes #990 a bug where the generator would introduce unnecessary union types for nullables
Taking a look at an OData action such as
createUploadSession
we have the schema as below.From this schema we see the response schema has the
anyOf
attribute similar to other odata actions such asgetSchedule
etc.Due to the code here, since the
anyOf
is at the top level (this doesn't seem to happen when theanyOf
property is present in a class/type property such as in the requestBody parameters in thegetSchedule
), the generator generates a union type which nests the desired type when the API will return theanyOf
type on the top level of the json response.This results in generating a request builder that returns a
CreateUploadSessionResponse
instance where theUploadSession
type is a nested property rather than the requestBuilder returning theUploadSession
. Ref hereQuestions
anyOf
list in these scenarios?cc @baywet
The text was updated successfully, but these errors were encountered: