OpenAPITools / OpenAPITools/openapi-generator

[BUG][KOTLIN] Model not generated when used as $ref in multipart/form-data requestBody

Open
#10,396 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
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

When using openApiGenerate with a yaml, model is not generated when used as a $ref inside a multipart/form-data requestBody.

If multipart/form-data is changed to application/json, the model will be generated.

openapi-generator version

5.2.0

OpenAPI declaration file content or url
openapi: 3.0.0
info:
  description: YAML for bug report
  version: '1.0'
  title: Bug report
tags:
  - name: Test
    description: Test
paths:

  /test/create:
    post:
      tags:
        - Test
      summary: Summary
      description: Description
      operationId: testCreate
      responses:
        '200':
          description: Successful operation
        '400':
          description: Invalid request
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - file
                - json
              properties:
                file:
                  type: string
                  format: binary
                json:
                  $ref: '#/components/schemas/SomeRefObject'

components:
  schemas:
    SomeRefObject:
      description: 'Some Ref Object'
      type: object
      required:
        - id
      properties:
        id:
          type: string
          description: 'Some ID'

Generation Details

Gradle: 7.2
Kotlin: 1.5.30
Java: 11

Also tested with: SerializationLibrary: jackson (2.12.3)

Steps to reproduce

Create a gradle file with dependencies and the org.openapi.generator plugin

Execute: gradle openApiGenerate

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the supplied OpenAPI YAML and run the Gradle openApiGenerate command using the Kotlin generator. Compare generation for the multipart/form-data and application/json variants; done means SomeRefObject is generated for the multipart request body.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
api, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.