-
Notifications
You must be signed in to change notification settings - Fork 124
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
[BUG] All generated methods return nullable types #670
Comments
Hi @DenisAnkh , could you please share swagger file (or part of it)? |
Hi @Vovanella95, here is the part of swagger file: "/teachers/{id}": {
"get": {
"tags": [
"Teachers"
],
"summary": "Get Teacher data by ID",
"operationId": "teachersGetTeacherById",
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "integer"
}
}
],
"responses": {
"200": {
"description": "successful operation",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/TeacherDto"
}
}
}
},
"400": {
"description": "Invalid id supplied"
},
"404": {
"description": "Teacher is not found"
}
},
"security": [
{
"bearerAuth": []
}
]
}
}, Currently we have rolled back to version 2.11.11 of swagger_dart_code_generator. The version generates correct code. Version 2.11.13 (as well as 2.11.12) generates different code with the same swagger file. Our current (working correct) pubspec.yaml:
|
Thanks @DenisAnkh ! Will handle it this week! |
Fixed in |
There are still models generating non-nullable properties when they are. So my whole models has "nullable: true" on properties, except the one that are just "$ref: XX". However, these properties are nullable in my model. Is the issue in the package i'm using to generate my swagger.json? "Cart": {
"type": "object",
"properties": {
"id": {
"type": "string",
"nullable": true
},
"name": {
"type": "string",
"nullable": true
},
"status": {
"$ref": "#/components/schemas/StatusEnum"
},
"mode": {
"$ref": "#/components/schemas/ModeEnum"
},
"accountId": {
"type": "string",
"nullable": true
},
"orgId": {
"type": "string",
"nullable": true
},
"createdAt": {
"type": "string",
"format": "date-time",
"nullable": true
},
"lastModified": {
"type": "string",
"format": "date-time",
"nullable": true
},
"richSynchronizedAt": {
"type": "string",
"format": "date-time",
"nullable": true
},
"billingAddress": {
"$ref": "#/components/schemas/CartAddress"
},
"logisticDetails": {
"$ref": "#/components/schemas/LogisticDetails"
},
"marketplaceLogisticDetailsList": {
"type": "array",
"items": {
"$ref": "#/components/schemas/LogisticDetails"
},
"nullable": true
},
"opcoCartId": {
"type": "string",
"nullable": true
},
"orderAdditionalInformation": {
"$ref": "#/components/schemas/OrderAdditionalInformation"
},
"includeAllSpas": {
"type": "boolean",
"nullable": true
},
"specialPriceAgreements": {
"type": "array",
"items": {
"$ref": "#/components/schemas/SpecialPriceAgreement"
},
"nullable": true
},
"project": {
"$ref": "#/components/schemas/Project"
},
"quote": {
"$ref": "#/components/schemas/Quote"
},
"approvalInfo": {
"$ref": "#/components/schemas/ApprovalInfo"
},
"refusalInfo": {
"$ref": "#/components/schemas/RefusalInfo"
},
"items": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Item"
},
"nullable": true
},
"itemsNotAdded": {
"type": "array",
"items": {
"$ref": "#/components/schemas/ItemNotAdded"
},
"nullable": true
},
"coupons": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Coupon"
},
"nullable": true
},
"contributors": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Contributor"
},
"nullable": true
},
"synchronizationErrors": {
"type": "array",
"items": {
"$ref": "#/components/schemas/SynchronizationError"
},
"nullable": true
},
"totalPrice": {
"$ref": "#/components/schemas/PriceField"
},
"totalPriceExcludingPromotions": {
"$ref": "#/components/schemas/PriceField"
},
"totalPromotions": {
"$ref": "#/components/schemas/PriceField"
},
"totalSurchargeTaxes": {
"$ref": "#/components/schemas/PriceField"
},
"totalPriceIncludingSurcharges": {
"$ref": "#/components/schemas/PriceField"
},
"totalPriceIncludingSurchargesAndShipping": {
"$ref": "#/components/schemas/PriceField"
},
"totalShippingCosts": {
"$ref": "#/components/schemas/PriceField"
},
"totalPriceIncludingTaxes": {
"$ref": "#/components/schemas/PriceField"
},
"totalPriceAllIncluded": {
"$ref": "#/components/schemas/PriceField"
},
"totalVatByPercentage": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Tax"
},
"nullable": true
},
"discountDetails": {
"type": "array",
"items": {
"$ref": "#/components/schemas/DiscountDetail"
},
"nullable": true
},
"messages": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Message"
},
"nullable": true
},
"persistentMessages": {
"type": "array",
"items": {
"$ref": "#/components/schemas/PersistentMessage"
},
"nullable": true
},
"products": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Product"
},
"nullable": true
}
},
"additionalProperties": false
}, |
Hi @frederikstonge , let me release new version first :) Please check behavior in |
@frederikstonge it's done |
It seems in version 2.11.13 signature of generated methods has been changed.
It was earlier (before version 2.11.13) - see:
TeacherDto
:Now all return types of generated methods are nullable - see:
TeacherDto?
:Version 2.11.13
The text was updated successfully, but these errors were encountered: