OpenAPITools / OpenAPITools/openapi-generator
[BUG] Library spring-boot generates incorrect Java syntax
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
openapi-generator version
id 'org.openapi.generator' version "5.2.1"
OpenAPI declaration file content or url
swagger: '2.0'
info:
version: '1.0.0'
title: Example API
contact:
name: No Name
email: example@example.com
url: https://example.com
host: example.com
schemes:
- https
basePath: /v2
paths:
/photos:
post:
summary: Photo upload
consumes:
- multipart/form-data
description: |
parameters:
- name: "photo[content]"
in: formData
description: file
required: true
type: file
responses:
201:
description: Success
schema:
type: object
properties:
photo:
type: object
properties:
id:
type: string
description: Photo ID
Generation Details
Config options:
[
dateLibrary: "java8-localdatetime",
skipDefaultInterface: "true",
serializableModel: "true",
interfaceOnly: "true",
hideGenerationTimestamp: "true",
useTags: "true",
library: "spring-boot",
reactive: "true"
]
Steps to reproduce
The generation result is:
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
@Validated
@Api(value = "Default", description = "the Default API")
public interface DefaultApi {
/**
* POST /photos : Photo upload
*
* @param photoContent file (required)
* @return Success (status code 201)
*/
@ApiOperation(value = "Photo upload", nickname = "photosPost", notes = "", response = InlineResponse201.class, tags={ })
@ApiResponses(value = {
@ApiResponse(code = 201, message = "Success", response = InlineResponse201.class) })
@RequestMapping(
method = RequestMethod.POST,
value = "/photos",
produces = { "*/*" },
consumes = { "multipart/form-data" }
)
Mono<ResponseEntity<InlineResponse201>> photosPost(@ApiParam(value = "file") @Valid @RequestPart(value = "photo[content]", required = true) Flux<Part> photo[content], @ApiIgnore final ServerWebExchange exchange);
}
Look at Flux<Part> photo[content] - it is not correct java syntax. Flux<Part> photoContent is expected.
Changing library option from spring-boot to spring-cloud solves problem, but reactive:"true" is necessary for me and it can be used only with spring-boot
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 by reproducing generation with the supplied OpenAPI YAML, the spring-boot library, and reactive=true using openapi-generator 5.2.1. Trace how the form-data parameter name photo[content] becomes the generated Java parameter, then verify that the output uses a valid identifier such as photoContent and remains compilable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi, spring-boot
- Domain
- api, backend, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100