OpenAPITools / OpenAPITools/openapi-generator
[BUG] [SPRING-CLOUD] UNKNOWN_BASE_TYPE when using multi-part content
Open
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)?
- What's the version of OpenAPI Generator used?
- Have you search for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Bounty to sponsor the fix (example)
Description
When I swap out a multip part in a request body object, the interface is generated incorrectly with UNKNOWN BASE TYPE
openapi-generator version
4.2.0
OpenAPI declaration file content or url
This yaml works
---
openapi: 3.0.2
info:
title: Test
version: 'v1'
description: Test
paths:
/foo:
post:
summary: Test
operationId: createFoo
requestBody:
required: true
content:
multipart/form-data:
schema:
type: object
properties:
file:
type: array
items:
type: string
format: binary
responses:
'201':
description: "Go"
ResponseEntity<Void> createFoo(@ApiParam(value = "file detail") @RequestParam("file") MultipartFile file);
This yaml is not working
---
openapi: 3.0.2
info:
title: Test
version: 'v1'
description: Test
paths:
/foo:
post:
summary: Test
operationId: createFoo
requestBody:
$ref: '#/components/requestBodies/MultiPartFile'
responses:
'201':
description: "Go"
components:
requestBodies:
MultiPartFile:
content:
multipart/form-data:
schema:
type: object
properties:
file:
type: array
items:
type: string
format: binary
description: Payload or user input is invalid. See error details in the payload for more information.
ResponseEntity<Void> createFoo(@ApiParam(value = "Payload or user input is invalid. See error details in the payload for more information." ) @Valid @RequestBody UNKNOWN_BASE_TYPE UNKNOWN_BASE_TYPE);
Command line used for generation
<generatorName>spring</generatorName>
<library>spring-cloud</library>
<java8>true</java8>
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 two OpenAPI YAML examples and the spring generator command using the spring-cloud library; compare generation for the inline multipart request body and the referenced request body. Trace why the referenced schema becomes UNKNOWN_BASE_TYPE, and verify that the generated method uses the expected MultipartFile parameter instead.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi, spring
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100