OpenAPITools / OpenAPITools/openapi-generator
[BUG] [kotlin] $refs to separate files are broken
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- 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?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
$refs are not followed when referencing local files
openapi-generator version
5.3.0
OpenAPI declaration file content or url
openapi: "3.0.2"
info:
title: API Title
version: "1.0"
servers:
- url: https://api.server.test/v1
paths:
/test:
post:
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/Request'
responses:
'200':
description: OK
components:
schemas:
Request:
$ref: './schemas/request.yaml'
Request:
type: object
properties:
someProp:
type: string
Generation Details
Maven plugin with kotlin generator with following config:
<configuration>
<inputSpec>openapi/openapi.yaml</inputSpec>
<generatorName>kotlin</generatorName>
<generateApis>true</generateApis>
<generateModels>true</generateModels>
</configuration>
Steps to reproduce
Run the openapi-generator-plugin, see that the generated API file is using kotlin.Any as a method parameter instead of a Request object. Request.kt is not even generated.
Suggest a fix
Follow $refs to other files from main file.
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 Maven plugin configuration and Kotlin generator using the provided main OpenAPI file and schemas/request.yaml. Reproduce the generation and trace how the local $ref is resolved. Done means Request.kt is generated and the API method uses Request instead of kotlin.Any.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin, openapi
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100