-
Notifications
You must be signed in to change notification settings - Fork 86
Open
Description
Use case
Assume we are working with an API that returns a List<String> for the owner's pet names.
There are 2 successful branches here:
- 200 - a body with appropriate content-length header and the list of pet name
- 204 - No-Content which results in content-length: 0. The owner does not yet have any pets
Currently, if both 200 and 204 are specified and No-Content response returns with empty body, an exception will be thrown.
Error: Null check operator used on a null value
because the generated code uses ! operator on .data field of result.
What I'm looking for is the ability to be able to do something like this:
openapi: 3.0.4
info:
title: Mini pets
version: "1.0"
paths:
/pets:
get:
summary: Gets the list of pets
responses:
200:
description: List of pet names
content:
application/json:
schema:
type: array
items:
type: string
204:
description: No pets yetProposal
In such situations, returning with a freezed union type would probably cover the usecase.
jayjah and cecbr
Metadata
Metadata
Assignees
Labels
No labels