Closed ahoehma closed 4 years ago
I am not sure whether the plugin is actually behaving differently than the Swagger framework itself. I mean we could add a sorting, as you suggest, but I am thinking whether this would more correctly be solved in Swagger itself as we are merely wrapping it.
This problem seems to be reoccurring quite often in the Swagger framework itself. There are many open issues about this, even from 2017:
https://github.com/swagger-api/swagger-core/issues/2775 https://github.com/swagger-api/swagger-core/issues/2828 https://github.com/swagger-api/swagger-core/pull/3266 https://github.com/swagger-api/swagger-core/issues/2400
What is the best way to solve this matter both properly and swiftly you reckon, @langecode ? How can I help?
Well, if there is that many open issued with Swagger Code it seems not very high priority and I do acknowledge it can be a problem if you want to do a simple diff between outputs (we actually did do a diff tool for OpenAPI specifications that does it semantically - however I do not think we ported that to OpenAPI 3 yet: https://github.com/openapi-tools/open-api-diff).
If it has value to you I think it would be ok to include a sorting option to the plugin as suggested by @ahoehma - I am not working much with Java these days so it is a little hard to find the time to implement it - but feel free to do a PR and I shall find the time to look through that.
@wanno-drijfhout @langecode @ahoehma We generated a pull request for this issue. This causes blocking problems when adopting this plugin.
@langecode I fear updating to the new version doesn't lead to a deterministic or sorted output. @hiddewie found a bug in the refactoring and created PR #50 .
Feedback ... now I'm using 2.1.4 and I still have some random jumps of paths in the output.json/yaml.
<plugin>
<groupId>io.openapitools.swagger</groupId>
<artifactId>swagger-maven-plugin</artifactId>
<version>${swagger-maven-plugin.version}</version>
<configuration>
<outputDirectory>${basedir}/src/openapi/</outputDirectory>
<outputFormats>JSON,YAML</outputFormats>
<prettyPrint>true</prettyPrint>
<attachSwaggerArtifact>true</attachSwaggerArtifact>
<swaggerConfig>
<info>
<title>SPICE Configuration Service API</title>
<license>
<name>The Siemens Inner Source License - 1.1</name>
<url>https://code.siemens.com/ebconf/spice-configuration-cluster/-/blob/develop/LICENSE</url>
</license>
<description></description>
<version>${api.version}</version>
</info>
</swaggerConfig>
</configuration>
<executions>
<execution>
<id>cc-configuration</id>
<phase>process-classes</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<resourcePackages>
<resourcePackage>com.siemens.spice.cc.rest.service.configuration</resourcePackage>
</resourcePackages>
<outputFilename>cc-${api.version}-configuration</outputFilename>
</configuration>
</execution>
<execution>
<id>cc-settings</id>
<phase>process-classes</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<resourcePackages>
<resourcePackage>com.siemens.spice.cc.rest.service.settings</resourcePackage>
</resourcePackages>
<outputFilename>cc-${api.version}-settings</outputFilename>
</configuration>
</execution>
<execution>
<id>cc-products</id>
<phase>process-classes</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<resourcePackages>
<resourcePackage>com.siemens.spice.cc.rest.service.products</resourcePackage>
</resourcePackages>
<outputFilename>cc-${api.version}-products</outputFilename>
</configuration>
</execution>
<execution>
<id>cc-brain</id>
<phase>process-classes</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<resourcePackages>
<resourcePackage>com.siemens.spice.cc.rest.service.brain</resourcePackage>
</resourcePackages>
<outputFilename>cc-${api.version}-brain</outputFilename>
</configuration>
</execution>
<execution>
<id>cc-history</id>
<phase>process-classes</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<resourcePackages>
<resourcePackage>com.siemens.spice.cc.rest.service.history</resourcePackage>
</resourcePackages>
<outputFilename>cc-${api.version}-history</outputFilename>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</plugin>
@ahoehma There seem to be more things that need to be sorted, e.g. https://github.com/openapi-tools/swagger-maven-plugin/pull/50#issuecomment-671770396. The current solution is a workaround, and should be solved in swagger-core). PRs and issues have also been referenced opened there.
Describe the bug I have a controller-class. I'm able to generate json and yaml. But every time I run the plugin the result looks different to the prev. one. This is not so helpfull because I put the result into my git-repo.
To Reproduce Simply run the generation multiple time without any change.
Expected behavior The generated json/yaml must create always the same output.
I tried to "fix" this behavior in io.openapitools.swagger.GenerateMojo.execute()
...