-
Notifications
You must be signed in to change notification settings - Fork 47
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
Nullable enums cause NPE #357
Comments
Can you provide a minimal API spec that causes the issue(s). I might get a chance to look at this this weekend |
Yeah I can try to fiddle something together later this evening, at least with the enum issue. |
This is what ChatGPT gave me, with only minor tweaking on my part to make both errors occur (nullable enum causing the whole generation to fail, and the List<Int> not being supported as query parameter): openapi: 3.0.3
info:
title: Nullable Enum Demo API
version: 1.0.0
paths:
/status:
get:
summary: Get the status of a resource
operationId: getStatus
parameters:
- name: values
in: query
description: A comma-separated list of integer values
required: false
schema:
type: array
items:
type: integer
responses:
'200':
description: Successful response
content:
application/json:
schema:
$ref: '#/components/schemas/DemoResponse'
components:
schemas:
DemoResponse:
type: object
properties:
status:
type: string
nullable: true
enum: [ "active", "inactive", "pending", null ] According to the OpenAPI documentation/specification it's essential that both |
Ah I just saw #237, so the integer list query param story is apparently already known. |
Hello,
I was trying to generate the client and model code for the German Brightsky API: https://brightsky.dev/docs/
Their OpenAPI Spec works flawlessly in the Swagger Editor, but when trying to generate the code with fabrikt, it simply fails due to
When I removed all
null
values from all the enums in the YAML it worked.A quick debugging session showed that the issue is there:
fabrikt/src/main/kotlin/com/cjbooms/fabrikt/util/KaizenParserExtensions.kt
Line 94 in d538e02
So that
toString()
call there needs to use the correct extension function forAny?
, and not the member method ofAny
. I don't know if that is enough, though.BUT: Even after removing all nullable enums, the generated client code (for OkHTTP) did not compile still. It tried to provide a
List<Int>
to a function that only acceptsList<String>
. That is the case for all thesource_id
parameters in the API spec.PS: I was using a Gradle build with the latest version 1.11.0 of the plugin, which in turn uses fabrikt 20.0.0.
The text was updated successfully, but these errors were encountered: