-
-
Notifications
You must be signed in to change notification settings - Fork 7k
[BUG] Error resolving complex Reference with path parameter #21058
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I managed to workaround this issue and keep on respecting the OAS, while hoping this will get fixed in the future. For those who are in the same case than me, here is my little contribution. Hopefully it will save lives 😁 Below is an excerpt of my pom.xml This will basically copy your swagger sources to the build dir, replace the Note, that if you are using Windows you will have to use URI format for inputSpec. (related to other issue: 14648 [...]
<properties>
<project.build.uri>${project.baseUri}/target</project.build.uri>
<project.src.swagger.baseDir>${project.basedir}/src/main/resources/swagger</project.src.swagger.baseDir>
<project.src.swagger.fileName>api.yaml</project.src.swagger.fileName>
<project.build.generatedSources.baseDir>${project.build.directory}/generated-sources/</project.build.generatedSources.baseDir>
<project.build.swagger.baseDir>${project.build.generatedSources.baseDir}/swagger</project.build.swagger.baseDir>
<openapi.generator.inputSpec>${project.build.uri}/generated-sources/swagger/${project.src.swagger.fileName}</openapi.generator.inputSpec>
<openapi.generator.output>${project.build.generatedSources.baseDir}/openapi</openapi.generator.output>
</properties>
[...]
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>convert-for-compatibility-openapi-generator</id>
<phase>generate-sources</phase>
<configuration>
<target>
<copy todir="${project.build.swagger.baseDir}">
<fileset dir="${project.src.swagger.baseDir}" />
</copy>
<!-- Since there is a bug in openapi-generator we are obliged to replace the { and } by %7B and %7D-->
<!-- https://github.com/OpenAPITools/openapi-generator/issues/21058-->
<replace file="${project.build.swagger.baseDir}/${project.src.swagger.fileName}" token="~1{" value="~1%7B" />
<replace file="${project.build.swagger.baseDir}/${project.src.swagger.fileName}" token="}'" value="%7D'" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>7.12.0</version>
<executions>
<execution>
<id>generate-models</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${openapi.generator.inputSpec}</inputSpec><!-- use of Uri otherwise not working on f***g Windows-->
<generatorName>spring</generatorName>
<output>${openapi.generator.output}</output>
<modelPackage>${project.groupId}.model</modelPackage>
<apiPackage>${project.groupId}.api</apiPackage>
<generateModels>true</generateModels>
<generateApis>true</generateApis>
<generateApiTests>false</generateApiTests>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build> |
Same for me ( |
Uh oh!
There was an error while loading. Please reload this page.
Bug Report Checklist
Description
I have a root OpenAPI declaration file that makes paths references to another declaration's path in another file.
The path in question has a path parameter
/my-resource/{my-path-param}
When trying to generate the models from the root declaration file, I'm getting the following error:
The problem is with the "{" behind the second ~1.
Other cases where no path parameter is provided, are working fine.
openapi-generator version
7.12.0
OpenAPI declaration file content or url
Root OpenAPI declaration file example
Sub OpenAPI declaration file example 'acls.yaml'
Generation Details
Steps to reproduce
root.yaml
acls.yaml
fileYou should get the following error stack
Related issues/PRs
Suggest a fix
EDIT: (04/14/2025)
As an ugly workaround, it seems that replacing
{
by%7B
and}
by%7D
can do the trick, but, unfortunately it does not respect the openapi specsThe text was updated successfully, but these errors were encountered: