Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #14934
Closed
Open
Issue created Mar 12, 2023 by Oleh Kurpiak@borschContributor5 of 6 checklist items completed5/6 checklist items

[BUG] issue with Spring required args constructor

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

After this change https://github.com/OpenAPITools/openapi-generator/pull/14822 now when adding <additionalModelTypeAnnotations>@lombok.experimental.SuperBuilder</additionalModelTypeAnnotations> compilation might be broken

If object have some required parameters then everything works fine, but as soon as you have object without required parameters you are getting model where only "all args constructor" is present(generated by lombok) and there is no "no arg constructor"

Before this change I usually configured my models with <additionalModelTypeAnnotations>@lombok.AllArgsConstructor;@lombok.NoArgsConstructor;@lombok.experimental.SuperBuilder</additionalModelTypeAnnotations> so at the end I got "all args" & "no args" constructor generated by lombok

openapi-generator version

6.5.0-SNAPSHOT (not released yet)

OpenAPI declaration file content or url

any model with at least one property and there are no required properties

Generation Details
                        <plugin>
				<groupId>org.openapitools</groupId>
				<artifactId>openapi-generator-maven-plugin</artifactId>
				<version>6.5.0-SNAPSHOT</version>
				<configuration>
					<generateSupportingFiles>true</generateSupportingFiles>
					<modelNameSuffix>Dto</modelNameSuffix>
					<generateApiTests>false</generateApiTests>
					<generateModelTests>false</generateModelTests>
					<generateApiDocumentation>false</generateApiDocumentation>
					<configOptions>
						<interfaceOnly>true</interfaceOnly>
						<dateLibrary>java8</dateLibrary>
						<useTags>true</useTags>
						<openApiNullable>false</openApiNullable>
						<skipDefaultInterface>true</skipDefaultInterface>
						<documentationProvider>springfox</documentationProvider>
					</configOptions>
				</configuration>
				<executions>
					<execution>
						<id>generate-openapi-for-backend</id>
						<goals>
							<goal>generate</goal>
						</goals>
						<phase>generate-resources</phase>
						<configuration>
							<inputSpec>${project.basedir}/src/main/resources/contract/_index_auto.yaml</inputSpec>
							<generatorName>spring</generatorName>
							<configOptions>
								<additionalModelTypeAnnotations>@lombok.AllArgsConstructor;@lombok.NoArgsConstructor;@lombok.experimental.SuperBuilder</additionalModelTypeAnnotations>
							</configOptions>
						</configuration>
					</execution>
				</executions>
			</plugin>
Steps to reproduce
Related issues/PRs

https://github.com/OpenAPITools/openapi-generator/pull/14822

Suggest a fix

add option generatedRequiredParametersConstructor=false. By default it should be false, because this new option will broke compilation as it's in my case

@alucas could you please implement this? Please ping if you have no time, then I can pick this one

Assignee
Assign to
Time tracking