OpenAPITools / OpenAPITools/openapi-generator
[BUG] [DIO] Dart Diox Next - doesn't allow `null` as json response
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
OpenApi schema allows for empty responses wich should not contain any data (see here). I would expect that in this case there is no actual consideration of the response body and we would at least allow an request with an optional Object like _dio.request<Object?>.
The API we are requesting from returns null in the response body, which then breaks the dart client client as it can not parse null to an object.
openapi-generator version
5.3.1
OpenAPI declaration file content or url
Actually any request which has a body containing null should create an exception. But here is our failing request.
/core/customer/paymentcards:
post:
responses:
"201":
description: Created
headers:
Location:
schema:
type: string
summary: Add new payment card
operationId: Add new payment card
requestBody:
content:
application/json:
schema:
type: object
required:
- successUrl
- failedUrl
- clientName
properties:
successUrl:
type: string
description: >-
URL for redirect after successful registration of a new
card.
`cardId=` is added to URL.
failedUrl:
type: string
description: URL for redirect when the registration fails.
clientName:
type: string
description: Used by the server to identify the App in use
clientOs:
type: string
description: iOS - 12.0 (string, required) - Stored serverside to make it
easier for the customer to distinguish his tokens in lists.
security:
- bearer: []
Generation Details
Dart Dio-Next.
Steps to reproduce
Set up an Api which responds with null as json in the response body. Create the client. Call the generated method and wait for the exception.
Suggest a fix
Use _dio.request<Object?> in appropriate cases
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the generated Dart Dio-Next method for the payment-card POST and trace its response parsing when the body is null. Reproduce the request described in the issue, then verify that nullable Object handling is used where appropriate; done means a null JSON response completes without a parsing exception.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart, openapi
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100