Description
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
I am trying to generate clients from OpenAPI Spec. I made sure to use 1.14.0
docker run -v ${PWD}/examples:/app/output mcr.microsoft.com/openapi/kiota:1.14.0 generate
Examples of invalid Python
import datetime
from __future__ import annotations
from dataclasses import dataclass, field
from kiota_abstractions.serialization import Parsable, ParseNode, SerializationWriter
from typing import Any, Callable, Dict, List, Optional, TYPE_CHECKING, Union
if TYPE_CHECKING:
from .cargo_model_attributes_destination_details import CargoModel_attributes_destinationDetails
from .cargo_model_attributes_origin_details import CargoModel_attributes_originDetails
from .event_model import EventModel
...
import datetime
from __future__ import annotations
from dataclasses import dataclass, field
from kiota_abstractions.serialization import Parsable, ParseNode, SerializationWriter
from typing import Any, Callable, Dict, List, Optional, TYPE_CHECKING, Union
...
Expected behavior
For all the future imports to remain at the top. But, I am new too Python so maybe it's a python version thing, but I couldn't find any more information and it does seem a bit odd.
How to reproduce
I have been using Powershell to generate clients for various specs. But this is one which has the issue:
Generated for https://developer.icis.com/portals/api/sites/icis-live-portal/liveportal/apis/lnganalyticsapi/download_spec
I was then looping through in Python and generating based on some configuration/customisation
docker run -v ${PWD}/examples:/app/output mcr.microsoft.com/openapi/kiota:1.14.0 generate `
--output /app/output/$language/$output `
-l $language `
-n $namespace `
-d $($spec.url) `
--clean-output `
--exclude-backward-compatible `
--additional-data false `
--class-name ApiClient `
--disable-validation-rules `
--log-level Debug
Open API description file
CargoModel:
type: object
description: 'Cargo flows along with details around the commercial nature of its trades. It also details occurrences like Ship-to-Ship transfers, partial deliveries and imported or exported volumes.'
properties:
id:
type: string
maxLength: 36
example: '20742'
description: Unique identifier of cargo.
type:
type: string
maxLength: 50
example: cargoes
description: Type of data.
attributes:
type: object
properties:
isReload:
type: boolean
description: Indicates if the cargo was re-exported.
example: false
isPartial:
type: boolean
description: Indicates if the vessel's cargo was partially delivered at the cargo destination.
example: false
isTradeChurn:
type: boolean
description: Indicates if the cargo has multiple buyers and/or sellers.
example: false
isSts:
type: boolean
description: Indicates if the cargo was a ship-to-ship transfer.
example: false
departureTime:
type: string
format: date-time
description: Departure time from cargo origin port.
minLength: 24
maxLength: 24
example: '2016-09-24T20:58:38.000Z'
arrivalTime:
type: string
nullable: true
format: date-time
description: Arrival time to cargo destination port.
minLength: 24
maxLength: 24
example: '2016-09-29T04:01:30.000Z'
originDetails:
type: object
description: Details about the cargo at the origin port.
properties:
mass:
type: number
format: integer
nullable: true
description: Mass of cargo at origin.
example: 8140
volume:
type: number
format: integer
nullable: true
description: Volume of cargo at origin.
example: 18107
energyContent:
type: number
format: integer
nullable: true
description: Energy content of cargo at origin.
example: 423293
confidenceKey:
type: string
nullable: true
enum:
- High
- Medium
- Low
- null
example: Low
description: Origin cargo details confidence level.
destinationDetails:
type: object
description: Details about the cargo at the destination port.
properties:
mass:
type: number
format: integer
nullable: true
description: Mass of cargo at destination.
example: 8108
volume:
type: number
format: integer
nullable: true
description: Volume of cargo at destination.
example: 18035
energyContent:
type: number
format: integer
nullable: true
description: Energy content of cargo at destination.
example: 421616
confidenceKey:
type: string
nullable: true
enum:
- High
- Medium
- Low
- null
example: Medium
description: Destination cargo details confidence level.
event:
$ref: '#/components/schemas/EventModel'
relationships:
type: object
properties:
voyages:
type: object
properties:
data:
type: array
items:
type: object
properties:
type:
type: string
maxLength: 50
example: voyages
description: Type of related data.
id:
type: string
maxLength: 36
example: '116613'
description: Related voyage Id.
originPort:
type: object
properties:
data:
type: object
properties:
type:
type: string
maxLength: 50
example: ports
description: Type of related data.
id:
type: string
maxLength: 36
example: '83'
description: Related port Id.
destinationPort:
type: object
properties:
data:
type: object
nullable: true
properties:
type:
type: string
maxLength: 50
example: ports
description: Type of related data.
id:
type: string
maxLength: 36
example: '2326'
description: Related port Id.
cargoSpecification:
type: object
properties:
data:
type: object
properties:
type:
type: string
maxLength: 50
example: cargoSpecifications
description: Type of related data.
id:
type: string
maxLength: 36
example: '1'
description: Related cargo specification Id.
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
Click to expand log
PS C:\Projects\test> .\generate-code.ps1 info: Kiota.Builder.KiotaBuilder[0] Cleaning output directory /app/output/Python/lnganalytics dbug: Kiota.Builder.KiotaBuilder[0] kiota version 1.14.0 dbug: Kiota.Builder.KiotaBuilder[0] cache file /tmp/kiota/cache/generation/5A0BABF09B68A6E28F55D7E23347DD3239C41A4BE33096C5882D067794222D1B/download_spec not found, downloading from https://developer.icis.com/portals/api/sites/icis-live-portal/liveportal/apis/lnganalyticsapi/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:02.2025130 warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1basinTightnessScenarios/get/responses/200/content/application~1vnd.api+json/example/data/0/id - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1basinTightnessScenarios/get/responses/200/content/application~1vnd.api+json/example/data/0/attributes/created - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1basinTightnessScenarios/get/responses/200/content/application~1vnd.api+json/example/data/0/attributes/month - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1basinTightnessScenarios/get/responses/200/content/application~1vnd.api+json/example/data/1/id - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1basinTightnessScenarios/get/responses/200/content/application~1vnd.api+json/example/data/1/attributes/created - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1basinTightnessScenarios/get/responses/200/content/application~1vnd.api+json/example/data/1/attributes/month - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1basinTightnessScenarios~1{id}/get/responses/200/content/application~1vnd.api+json/example/data/id - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1basinTightnessScenarios~1{id}/get/responses/200/content/application~1vnd.api+json/example/data/attributes/created - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1basinTightnessScenarios~1{id}/get/responses/200/content/application~1vnd.api+json/example/data/attributes/month - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1cargoes/get/responses/200/content/application~1vnd.api+json/examples/example/value/data/0/attributes/originDetails/mass - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1cargoes/get/responses/200/content/application~1vnd.api+json/examples/example/value/data/0/attributes/originDetails/volume - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1cargoes/get/responses/200/content/application~1vnd.api+json/examples/example/value/data/0/attributes/originDetails/energyContent - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1cargoes/get/responses/200/content/application~1vnd.api+json/examples/example/value/data/0/attributes/destinationDetails/mass - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1cargoes/get/responses/200/content/application~1vnd.api+json/examples/example/value/data/0/attributes/destinationDetails/volume - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1cargoes/get/responses/200/content/application~1vnd.api+json/examples/example/value/data/0/attributes/destinationDetails/energyContent - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1cargoes/get/responses/200/content/application~1vnd.api+json/examples/example/value/data/1/attributes/originDetails/mass - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1cargoes/get/responses/200/content/application~1vnd.api+json/examples/example/value/data/1/attributes/originDetails/volume - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1cargoes/get/responses/200/content/application~1vnd.api+json/examples/example/value/data/1/attributes/originDetails/energyContent - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1cargoes/get/responses/200/content/application~1vnd.api+json/examples/example/value/data/1/attributes/destinationDetails/mass - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1cargoes/get/responses/200/content/application~1vnd.api+json/examples/example/value/data/1/attributes/destinationDetails/volume - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1cargoes/get/responses/200/content/application~1vnd.api+json/examples/example/value/data/1/attributes/destinationDetails/energyContent - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1cargoes~1{id}/get/responses/200/content/application~1vnd.api+json/example/data/attributes/originDetails/mass - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1cargoes~1{id}/get/responses/200/content/application~1vnd.api+json/example/data/attributes/originDetails/volume - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1cargoes~1{id}/get/responses/200/content/application~1vnd.api+json/example/data/attributes/originDetails/energyContent - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1cargoes~1{id}/get/responses/200/content/application~1vnd.api+json/example/data/attributes/destinationDetails/mass - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1cargoes~1{id}/get/responses/200/content/application~1vnd.api+json/example/data/attributes/destinationDetails/volume - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1cargoes~1{id}/get/responses/200/content/application~1vnd.api+json/example/data/attributes/destinationDetails/energyContent - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1charters/get/responses/200/content/application~1vnd.api+json/examples/example/value/data/0/attributes/startDateEarliest - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1charters/get/responses/200/content/application~1vnd.api+json/examples/example/value/data/0/attributes/startDateLatest - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1charters/get/responses/200/content/application~1vnd.api+json/examples/example/value/data/0/attributes/endDateEarliest - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1charters/get/responses/200/content/application~1vnd.api+json/examples/example/value/data/0/attributes/endDateLatest - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1charters/get/responses/200/content/application~1vnd.api+json/examples/example/value/data/1/attributes/startDateEarliest - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1charters/get/responses/200/content/application~1vnd.api+json/examples/example/value/data/1/attributes/startDateLatest - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1charters/get/responses/200/content/application~1vnd.api+json/examples/example/value/data/1/attributes/endDateEarliest - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1charters/get/responses/200/content/application~1vnd.api+json/examples/example/value/data/1/attributes/endDateLatest - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1charters~1{id}/get/responses/200/content/application~1vnd.api+json/example/data/attributes/startDateEarliest - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1charters~1{id}/get/responses/200/content/application~1vnd.api+json/example/data/attributes/startDateLatest - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1charters~1{id}/get/responses/200/content/application~1vnd.api+json/example/data/attributes/endDateEarliest - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1charters~1{id}/get/responses/200/content/application~1vnd.api+json/example/data/attributes/endDateLatest - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1forecasts/get/responses/200/content/application~1vnd.api+json/examples/example/value/data/0/attributes/publishDate - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1forecasts/get/responses/200/content/application~1vnd.api+json/examples/example/value/data/0/attributes/startDate - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1forecasts/get/responses/200/content/application~1vnd.api+json/examples/example/value/data/0/attributes/endDate - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1forecasts/get/responses/200/content/application~1vnd.api+json/examples/example/value/data/1/attributes/publishDate - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1forecasts/get/responses/200/content/application~1vnd.api+json/examples/example/value/data/1/attributes/startDate - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1forecasts/get/responses/200/content/application~1vnd.api+json/examples/example/value/data/1/attributes/endDate - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1forecasts~1{id}/get/responses/200/content/application~1vnd.api+json/example/data - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1forecastValues/get/responses/200/content/application~1vnd.api+json/examples/example/value/data/0/attributes/date - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1forecastValues/get/responses/200/content/application~1vnd.api+json/examples/example/value/data/1/attributes/date - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1forecastValues~1{id}/get/responses/200/content/application~1vnd.api+json/example/data - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1netbacks/get/responses/200/content/application~1vnd.api+json/example/data/0/attributes/created - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1netbacks/get/responses/200/content/application~1vnd.api+json/example/data/0/attributes/costAtOrigin - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1netbacks/get/responses/200/content/application~1vnd.api+json/example/data/0/attributes/bunkerPrice - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1netbacks/get/responses/200/content/application~1vnd.api+json/example/data/0/attributes/absoluteProfit - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1netbacks/get/responses/200/content/application~1vnd.api+json/example/data/1/attributes/created - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1netbacks/get/responses/200/content/application~1vnd.api+json/example/data/1/attributes/costAtOrigin - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1netbacks/get/responses/200/content/application~1vnd.api+json/example/data/1/attributes/bunkerPrice - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1netbacks/get/responses/200/content/application~1vnd.api+json/example/data/1/attributes/absoluteProfit - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1netbacks~1{id}/get/responses/200/content/application~1vnd.api+json/example/data/attributes/created - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1netbacks~1{id}/get/responses/200/content/application~1vnd.api+json/example/data/attributes/costAtOrigin - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1netbacks~1{id}/get/responses/200/content/application~1vnd.api+json/example/data/attributes/bunkerPrice - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1netbacks~1{id}/get/responses/200/content/application~1vnd.api+json/example/data/attributes/absoluteProfit - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1transactions/get/responses/200/content/application~1vnd.api+json/example/data/0/attributes/transactionOrder - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1transactions/get/responses/200/content/application~1vnd.api+json/example/data/0/attributes/price/high - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1transactions/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/~1transactions/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/~1transactions/get/responses/200/content/application~1vnd.api+json/example/data/1/attributes/transactionOrder - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1transactions/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/~1transactions/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/~1transactions~1{id}/get/responses/200/content/application~1vnd.api+json/example/data/attributes/transactionOrder - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1transactions~1{id}/get/responses/200/content/application~1vnd.api+json/example/data/attributes/price/high - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1transactions~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/~1transactions~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/~1vessels/get/responses/200/content/application~1vnd.api+json/example/data/0/attributes/capacity - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1vessels/get/responses/200/content/application~1vnd.api+json/example/data/1/attributes/capacity - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/paths/~1vessels~1{id}/get/responses/200/content/application~1vnd.api+json/example/data/attributes/capacity - Data and type mismatch found. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/components/schemas/CargoModel/properties/attributes/properties/originDetails/properties/mass - The format integer is not supported by Kiota for the type number and the string type will be used. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/components/schemas/CargoModel/properties/attributes/properties/originDetails/properties/volume - The format integer is not supported by Kiota for the type number and the string type will be used. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/components/schemas/CargoModel/properties/attributes/properties/originDetails/properties/energyContent - The format integer is not supported by Kiota for the type number and the string type will be used. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/components/schemas/CargoModel/properties/attributes/properties/destinationDetails/properties/mass - The format integer is not supported by Kiota for the type number and the string type will be used. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/components/schemas/CargoModel/properties/attributes/properties/destinationDetails/properties/volume - The format integer is not supported by Kiota for the type number and the string type will be used. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/components/schemas/CargoModel/properties/attributes/properties/destinationDetails/properties/energyContent - The format integer is not supported by Kiota for the type number and the string type will be used. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/components/schemas/ForecastValueModel/properties/relationships/properties/forecast/properties/data/properties/id - The format string is not supported by Kiota for the type string and the string type will be used. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/components/schemas/TransactionModel/properties/attributes/properties/transactionOrder - The format int is not supported by Kiota for the type number and the string type will be used. warn: Kiota.Builder.KiotaBuilder[0] OpenAPI warning: #/components/schemas/VesselModel/properties/attributes/properties/capacity - The format int 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.1235163 dbug: Kiota.Builder.KiotaBuilder[0] step 3 - updating generation configuration from kiota extension - took 00:00:00.0000954 dbug: Kiota.Builder.KiotaBuilder[0] step 4 - filtering API paths with patterns - took 00:00:00.0025663 dbug: Kiota.Builder.KiotaBuilder[0] step 5 - checking whether the output should be updated - took 00:00:00.0147879 dbug: Kiota.Builder.KiotaBuilder[0] step 6 - create uri space - took 00:00:00.0020997 dbug: Kiota.Builder.KiotaBuilder[0] InitializeInheritanceIndex 00:00:00.0020691 dbug: Kiota.Builder.KiotaBuilder[0] CreateRequestBuilderClass 00:00:00 dbug: Kiota.Builder.KiotaBuilder[0] MapTypeDefinitions 00:00:00.0170261 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.1007565 dbug: Kiota.Builder.KiotaBuilder[0] 99ms: Language refinement applied dbug: Kiota.Builder.KiotaBuilder[0] step 8 - refine by language - took 00:00:00.0997416 dbug: Kiota.Builder.KiotaBuilder[0] step 9 - writing files - took 00:00:00.9085176 dbug: Kiota.Builder.KiotaBuilder[0] cache file /tmp/kiota/cache/generation/5A0BABF09B68A6E28F55D7E23347DD3239C41A4BE33096C5882D067794222D1B/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.0176999 Generation completed successfully dbug: Kiota.Builder.KiotaBuilder[0] Api manifest path: /app/apimanifest.jsonOther information
import datetime
from __future__ import annotations
from dataclasses import dataclass, field
from kiota_abstractions.serialization import Parsable, ParseNode, SerializationWriter
from typing import Any, Callable, Dict, List, Optional, TYPE_CHECKING, Union
if TYPE_CHECKING:
from .cargo_model_attributes_destination_details import CargoModel_attributes_destinationDetails
from .cargo_model_attributes_origin_details import CargoModel_attributes_originDetails
from .event_model import EventModel
@dataclass
class CargoModel_attributes(Parsable):
@staticmethod
def create_from_discriminator_value(parse_node: Optional[ParseNode] = None) -> CargoModel_attributes:
"""
Creates a new instance of the appropriate class based on discriminator value
param parse_node: The parse node to use to read the discriminator value and create the object
Returns: CargoModel_attributes
"""
if not parse_node:
raise TypeError("parse_node cannot be null.")
return CargoModel_attributes()
def get_field_deserializers(self,) -> Dict[str, Callable[[ParseNode], None]]:
"""
The deserialization information for the current model
Returns: Dict[str, Callable[[ParseNode], None]]
"""
from .cargo_model_attributes_destination_details import CargoModel_attributes_destinationDetails
from .cargo_model_attributes_origin_details import CargoModel_attributes_originDetails
from .event_model import EventModel
from .cargo_model_attributes_destination_details import CargoModel_attributes_destinationDetails
from .cargo_model_attributes_origin_details import CargoModel_attributes_originDetails
from .event_model import EventModel
fields: Dict[str, Callable[[Any], None]] = {
"arrivalTime": lambda n : setattr(self, 'arrival_time', n.get_datetime_value()),
"departureTime": lambda n : setattr(self, 'departure_time', n.get_datetime_value()),
"destinationDetails": lambda n : setattr(self, 'destination_details', n.get_object_value(CargoModel_attributes_destinationDetails)),
"event": lambda n : setattr(self, 'event', n.get_object_value(EventModel)),
"isPartial": lambda n : setattr(self, 'is_partial', n.get_bool_value()),
"isReload": lambda n : setattr(self, 'is_reload', n.get_bool_value()),
"isSts": lambda n : setattr(self, 'is_sts', n.get_bool_value()),
"isTradeChurn": lambda n : setattr(self, 'is_trade_churn', n.get_bool_value()),
"originDetails": lambda n : setattr(self, 'origin_details', n.get_object_value(CargoModel_attributes_originDetails)),
}
return fields
def serialize(self,writer: SerializationWriter) -> None:
"""
Serializes information the current object
param writer: Serialization writer to use to serialize this model
Returns: None
"""
if not writer:
raise TypeError("writer cannot be null.")
writer.write_datetime_value("arrivalTime", self.arrival_time)
writer.write_datetime_value("departureTime", self.departure_time)
writer.write_object_value("destinationDetails", self.destination_details)
writer.write_object_value("event", self.event)
writer.write_bool_value("isPartial", self.is_partial)
writer.write_bool_value("isReload", self.is_reload)
writer.write_bool_value("isSts", self.is_sts)
writer.write_bool_value("isTradeChurn", self.is_trade_churn)
writer.write_object_value("originDetails", self.origin_details)
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Activity
baywet commentedon May 6, 2024
Hi @pjmagee
Thanks for the detailed information and for using kiota.
For reference, this is the section of the code outputting this section.
kiota/src/Kiota.Builder/Writers/Python/CodeUsingWriter.cs
Line 21 in ec1639e
It is strange the order of imports is not consistent with other clients
Out of curiosity, if you manually edit the code to move the future import line to the top, does it solve the error message ?
pjmagee commentedon May 6, 2024
Yes it does, I use Jetbrains PyCharm and it suggests to move it to the top, which I do. Then the executions runs fine.
I am coming across other errors still in some other files and sometimes also files with this issue, to do with module import however, I am not confident to report it as a Kiota issue yet, as the OpenAPI Specs I am dealing with have issues themselves as well, and im trying to understand if its our definitions which are broken or we wrote them without fully understanding the spec, or if its a Kiota problem.
pjmagee commentedon May 6, 2024
Please feel free to use the OpenAPI Spec listed in the page to reproduce it. The OpenAPI specs are public
6 remaining items
pjmagee commentedon Jun 10, 2024
Just to say, this one is kind of breaking the entire Python SDK, since it means all generated code is invalid. So people using the Python SDK need to use the IDE or some tool to move ALL future imports.
WillMorrisonEnspi commentedon Mar 3, 2025
isort worked for me to fix this issue.
rcleveng commentedon Jun 7, 2025
I added this to the pull request for one of the investigations, but it's probably better here.
I'm happy to send a PR to change the image. There may be some way to set the runtimeconfig to use global invariant mode and also fix it, but I'm not a dotnet programmer at all, so that's a bit beyond me.
It's certainly the chiseled [variants](See https://github.com/dotnet/dotnet-docker/blob/main/documentation/image-variants.md) of the distribution, that's the difference This diff fixes it. I don't know enough about dotnet to know what exactly is causing this.
According to the docs:
By default, these images do not include icu or tzdata, meaning that these images
only work with apps that are configured for globalization-invariant mode.
See https://learn.microsoft.com/en-us/dotnet/core/runtime-config/globalization
baywet commentedon Jun 9, 2025
@rcleveng Thank you for the additional information.
So you're effectively saying this behaviour is only happening with the docker image? You're not able to reproduce it with the "executable" from the release page?
The main motivation for using chiseled base images was to reduce the size of the overall image.
It might be worth trying with the chiseled extra image to see if that makes a difference.
rcleveng commentedon Jun 9, 2025
@baywet That is correct. I tested against the release linux-x64 release binary as well as one I built myself from the repository. I can only reproduce it with the chiseled container image (and have rebuilt the docker image using that base as well to verify that it's the only change).
[update]
This doesn't reproduce with the mcr.microsoft.com/dotnet/runtime:9.0-noble-chiseled-extra image.
rcleveng commentedon Jun 9, 2025
Here's how I'm testing if this helps, it's everything needed to reproduce.
baywet commentedon Jun 9, 2025
Thank you for the additional information.
Is this something you'd like to submit a pull request for provided some guidance?
rcleveng commentedon Jun 9, 2025
Sure, happy to send a PR.
Use the chiseled-extras image so imports of __future__ are first.
Use the chiseled-extras image so imports of __future__ are first. (#6633
rcleveng commentedon Jun 9, 2025
Thanks @baywet I may follow up with a code-only fix if I can figure that one out and send a PR for that, perfect is the enemy of good, and all that.