-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Closed
Closed
Copy link
Labels
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
A sample yaml file whose response won't be turned into a type and instead, its client type will be Any:
openapi: 3.1.0
info:
title: Bug Report API
version: 1.0.0
paths:
/bug-report:
post:
summary: Submit a bug report
operationId: submitBugReport
responses:
'200':
$ref: '#/components/responses/BugReportResponse'
components:
responses:
BugReportResponse:
description: This should be generated
content:
application/json:
schema:
type: object
properties:
id:
type: integer
status:
type: string
This on the other hand, will resolve as expected:
openapi: 3.1.0
info:
title: Bug Report API
version: 1.0.0
paths:
/bug-report:
post:
summary: Submit a bug report
operationId: submitBugReport
responses:
'200':
description: Bug report successfully submitted
content:
application/json:
schema:
$ref: '#/components/schemas/BugReportResponse'
components:
schemas:
BugReportResponse:
type: object
properties:
id:
type: string
status:
type: string
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
First spec's output where the type cannot be determined:
/**
* Submit a bug report
*
* @return void
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
* @throws UnsupportedOperationException If the API returns an informational or redirection response
* @throws ClientException If the API returns a client error response
* @throws ServerException If the API returns a server error response
*/
@Throws(IllegalStateException::class, IOException::class, UnsupportedOperationException::class, ClientException::class, ServerException::class)
fun submitBugReport() : Unit {
Second spec where the type is correctly inferred:
/**
* Submit a bug report
*
* @return BugReportResponse or null
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
* @throws UnsupportedOperationException If the API returns an informational or redirection response
* @throws ClientException If the API returns a client error response
* @throws ServerException If the API returns a server error response
*/
@Suppress("UNCHECKED_CAST")
@Throws(IllegalStateException::class, IOException::class, UnsupportedOperationException::class, ClientException::class, ServerException::class)
fun submitBugReport() : BugReportResponse? {
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
openapi-generator version
OpenAPI declaration file content or url
Generation Details
openapi-generator-cli generate -i spec.yml -g kotlin -o gen --library jvm-okhttp4