kiota
kiota copied to clipboard
[Python] array anyOf generating invalid Python code
What are you generating using Kiota, clients or plugins?
API Client/SDK
In what context or format are you using Kiota?
Linux executable
Client library/SDK language
Python
Describe the bug
Invalid python code causes python runtime exceptions to occur due to the generated python not being valid for anyOf
.
Expected behavior
Python anyOf to produce python code that doesnt cause the runtime exceptions to occur when trying to call endpoints from the generated client
How to reproduce
'200':
description: The HTTP `200 OK` success status response code indicates that the request has succeeded.
content:
application/vnd.api+json:
schema:
type: object
description: A list of LocationSpread entities.
properties:
links:
type: object
properties:
next:
type: string
nullable: true
data:
type: array
items:
$ref: '#/components/schemas/LocationSpreadModel'
included:
type: array
items:
anyOf:
- $ref: '#/components/schemas/PeriodModel'
- $ref: '#/components/schemas/LocationSpreadSpecificationModel'
Open API description file
Kiota Version
1.14.0
Latest Kiota version known to work for scenario above?(Not required)
No response
Known Workarounds
No response
Configuration
No response
Debug output
PS C:\Projects\icis-openapi-kiota> .\generate-kiota-api-clients.ps1 Generating for https://developer.icis.com/portals/api/sites/icis-live-portal/liveportal/apis/energyapi/download_spec info: Kiota.Builder.KiotaBuilder[0] Cleaning output directory /app/output/Python/energy dbug: Kiota.Builder.KiotaBuilder[0] kiota version 1.14.0 dbug: Kiota.Builder.KiotaBuilder[0] cache file /tmp/kiota/cache/generation/BA16C3B0119BBFE2AA3E7CA599D573E64E2A6E1D154015CF57C24062ED34671C/download_spec not found, downloading from https://developer.icis.com/portals/api/sites/icis-live-portal/liveportal/apis/energyapi/download_spec info: Kiota.Builder.KiotaBuilder[0] loaded description from remote source dbug: Kiota.Builder.KiotaBuilder[0] step 1 - reading the stream - took 00:00:01.0235017 warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1basisPriceAssessments/get/responses/200/content/application~1vnd.api+json/example/data/0/attributes/createdForDate - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1basisPriceAssessments/get/responses/200/content/application~1vnd.api+json/example/data/0/attributes/volatilityIndex - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1basisPriceAssessments/get/responses/200/content/application~1vnd.api+json/example/data/0/attributes/diffToPrevBasisMid - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1basisPriceAssessments/get/responses/200/content/application~1vnd.api+json/example/data/1/attributes/createdForDate - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1basisPriceAssessments/get/responses/200/content/application~1vnd.api+json/example/data/1/attributes/volatilityIndex - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1basisPriceAssessments~1{id}/get/responses/200/content/application~1vnd.api+json/example/data/attributes/createdForDate - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1basisPriceAssessments~1{id}/get/responses/200/content/application~1vnd.api+json/example/data/attributes/volatilityIndex - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1basisPriceAssessments~1{id}/get/responses/200/content/application~1vnd.api+json/example/data/attributes/diffToPrevBasisMid - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1dataEvents/get/responses/200/content/application~1vnd.api+json/example/data/0/attributes/createdForDate - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1dataEvents/get/responses/200/content/application~1vnd.api+json/example/data/1/attributes/createdForDate - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1indices/get/responses/200/content/application~1vnd.api+json/example/data/0/attributes/createdForDate - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1indices/get/responses/200/content/application~1vnd.api+json/example/data/0/attributes/volume - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1indices/get/responses/200/content/application~1vnd.api+json/example/data/0/attributes/numOfTrades - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1indices/get/responses/200/content/application~1vnd.api+json/example/data/1/attributes/createdForDate - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1indices/get/responses/200/content/application~1vnd.api+json/example/data/1/attributes/volume - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1indices/get/responses/200/content/application~1vnd.api+json/example/data/1/attributes/numOfTrades - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1indices~1{id}/get/responses/200/content/application~1vnd.api+json/example/data/attributes/createdForDate - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1indices~1{id}/get/responses/200/content/application~1vnd.api+json/example/data/attributes/volume - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1indices~1{id}/get/responses/200/content/application~1vnd.api+json/example/data/attributes/numOfTrades - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1locationSpreads/get/responses/200/content/application~1vnd.api+json/example/data/0/attributes/createdForDate - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1locationSpreads/get/responses/200/content/application~1vnd.api+json/example/data/1/attributes/createdForDate - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1locationSpreads~1{id}/get/responses/200/content/application~1vnd.api+json/example/data/attributes/createdForDate - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1periods/get/responses/200/content/application~1vnd.api+json/example/data/0/attributes/referenceDate - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1periods/get/responses/200/content/application~1vnd.api+json/example/data/0/attributes/startDate - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1periods/get/responses/200/content/application~1vnd.api+json/example/data/0/attributes/endDate - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1periods/get/responses/200/content/application~1vnd.api+json/example/data/1/attributes/referenceDate - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1periods/get/responses/200/content/application~1vnd.api+json/example/data/1/attributes/startDate - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1periods/get/responses/200/content/application~1vnd.api+json/example/data/1/attributes/endDate - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1periods~1{id}/get/responses/200/content/application~1vnd.api+json/example/data/attributes/referenceDate - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1periods~1{id}/get/responses/200/content/application~1vnd.api+json/example/data/attributes/startDate - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1periods~1{id}/get/responses/200/content/application~1vnd.api+json/example/data/attributes/endDate - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1priceAssessments/get/responses/200/content/application~1vnd.api+json/example/data/0/attributes/createdForDate - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1priceAssessments/get/responses/200/content/application~1vnd.api+json/example/data/0/attributes/volatilityIndex - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1priceAssessments/get/responses/200/content/application~1vnd.api+json/example/data/1/attributes/createdForDate - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1priceAssessments/get/responses/200/content/application~1vnd.api+json/example/data/1/attributes/volatilityIndex - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1priceAssessments~1{id}/get/responses/200/content/application~1vnd.api+json/example/data/attributes/createdForDate - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1priceAssessments~1{id}/get/responses/200/content/application~1vnd.api+json/example/data/attributes/volatilityIndex - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1sparkAndDarkSpreads/get/responses/200/content/application~1vnd.api+json/example/data/0/attributes/createdForDate - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1sparkAndDarkSpreads/get/responses/200/content/application~1vnd.api+json/example/data/1/attributes/createdForDate - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1sparkAndDarkSpreads~1{id}/get/responses/200/content/application~1vnd.api+json/example/data/attributes/createdForDate - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1trades/get/responses/200/content/application~1vnd.api+json/example/data/0/attributes/createdForDate - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1trades/get/responses/200/content/application~1vnd.api+json/example/data/0/attributes/volume - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1trades/get/responses/200/content/application~1vnd.api+json/example/data/0/attributes/totalVolume - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1trades/get/responses/200/content/application~1vnd.api+json/example/data/1/attributes/createdForDate - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1trades/get/responses/200/content/application~1vnd.api+json/example/data/1/attributes/volume - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1trades/get/responses/200/content/application~1vnd.api+json/example/data/1/attributes/totalVolume - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1trades~1{id}/get/responses/200/content/application~1vnd.api+json/example/data/attributes/createdForDate - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1trades~1{id}/get/responses/200/content/application~1vnd.api+json/example/data/attributes/volume - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1trades~1{id}/get/responses/200/content/application~1vnd.api+json/example/data/attributes/totalVolume - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/components/schemas/IndexModel/properties/attributes/properties/numOfTrades - The format integer is not supported by Kiota for the type number and the string type will be used. dbug: Kiota.Builder.KiotaBuilder[0] step 2 - parsing the document - took 00:00:00.1286369 dbug: Kiota.Builder.KiotaBuilder[0] step 3 - updating generation configuration from kiota extension - took 00:00:00.0001125 dbug: Kiota.Builder.KiotaBuilder[0] step 4 - filtering API paths with patterns - took 00:00:00.0026473 dbug: Kiota.Builder.KiotaBuilder[0] step 5 - checking whether the output should be updated - took 00:00:00.0193923 dbug: Kiota.Builder.KiotaBuilder[0] step 6 - create uri space - took 00:00:00.0024655 dbug: Kiota.Builder.KiotaBuilder[0] InitializeInheritanceIndex 00:00:00.0031273 dbug: Kiota.Builder.KiotaBuilder[0] CreateRequestBuilderClass 00:00:00 dbug: Kiota.Builder.KiotaBuilder[0] MapTypeDefinitions 00:00:00.0218516 dbug: Kiota.Builder.KiotaBuilder[0] TrimInheritedModels 00:00:00 dbug: Kiota.Builder.KiotaBuilder[0] CleanUpInternalState 00:00:00 dbug: Kiota.Builder.KiotaBuilder[0] step 7 - create source model - took 00:00:00.0900220 dbug: Kiota.Builder.KiotaBuilder[0] 127ms: Language refinement applied dbug: Kiota.Builder.KiotaBuilder[0] step 8 - refine by language - took 00:00:00.1278204 dbug: Kiota.Builder.KiotaBuilder[0] step 9 - writing files - took 00:00:01.0558486 dbug: Kiota.Builder.KiotaBuilder[0] cache file /tmp/kiota/cache/generation/BA16C3B0119BBFE2AA3E7CA599D573E64E2A6E1D154015CF57C24062ED34671C/download_spec is up to date and clearCache is False, using it info: Kiota.Builder.KiotaBuilder[0] loaded description from remote source dbug: Kiota.Builder.KiotaBuilder[0] step 10 - writing lock file - took 00:00:00.0130857 Generation completed successfully dbug: Kiota.Builder.KiotaBuilder[0] Api manifest path: /app/apimanifest.json
Other information
I'm aware of the other errors coming up the output, but I dont think those impact the include
with anyOf
not working.
It DOES generate the classes, however, Python seems to have an issue in recognising the imports and using the class. See line 53, even PyCharm is not sure what class is being referred to, despite the class being generated below. Is it because the class is nested within the response class?