Model types do not get generated correctly when referenced via an array
Sorry, I couldn't get this any simpler, but if you generate this you will see that the model types that are referenced in the array type, do not get generated properly. They do get emitted as types, but they don't have the property inheritance relationship and they have no properties.
openapi: '3.0.0'
info:
title: Test
version: '1.0'
paths:
"/collection":
get:
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/itemArray"
components:
schemas:
itemArray:
type: object
oneOf:
- $ref: "#/components/schemas/catArray" # cat does not get properties or base type
- $ref: "#/components/schemas/dogArray" # dog does not get properties or base type
- $ref: "#/components/schemas/frogArray" # frog does not get properties
- $ref: "#/components/schemas/squirrel" # squirrel works
catArray:
type: array
items:
$ref: "#/components/schemas/cat"
cat:
allOf:
- $ref: "#/components/schemas/animal"
- type: object
properties:
meow:
type: string
dogArray:
type: array
items:
$ref: "#/components/schemas/dog"
dog:
allOf:
- $ref: "#/components/schemas/animal"
- type: object
properties:
woof:
type: string
frog:
type: object
properties:
croak:
type: string
frogArray:
type: array
items:
$ref: "#/components/schemas/frog"
squirrel:
type: object
properties:
chitter:
type: string
animal:
type: object
properties:
name:
type: string
Union and intersection of array types were excluded from the initial composed types implementation. Or at least this is what I took away from our discussions. Besides projecting the right types, it poses a lot of challenges during deserialization. So unless we decide to support that initial exclusion with a thorough implementation spec, I think we should consider all of these edge cases to avoid playing whack a mole.
I think the best thing to do at this point is to take the time to write a proper analysis of what additional vocab we need to do in JSON Schema in order to allow developer to properly communicate how types should be projected. Until we do that, we shouldn't try and piecemeal solve issues in Kiota. I just wanted to capture this issue because it showed up in the NightScout API.
@darrelmiller can you please try with the latest preview from yesterday and confirm whether you observe the problem? We've made significant improvements to the handling of allof edge scenarios with #4668 and #4381
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.