Fix the problem of inconsistent OpenAPI generation (#3954)

#### What type of PR is this?

/kind bug
/area core
/milestone 2.6.x

#### What this PR does / why we need it:

Sort properties before building.

#### Which issue(s) this PR fixes:

Fixes https://github.com/halo-dev/halo/issues/3944

#### Special notes for your reviewer:

Try to generate api client several times.

#### Does this PR introduce a user-facing change?

```release-note
None
```
pull/3941/head
John Niang 2023-05-16 15:04:18 +08:00 committed by GitHub
parent 136bd4e91f
commit 88597ac137
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 26 additions and 22 deletions

View File

@ -40,7 +40,11 @@ public final class QueryParamBuildUtil {
var properties = (Map<String, Schema>) resolvedSchema.schema.getProperties();
var requiredNames = defaultIfNull(resolvedSchema.schema.getRequired(),
Collections.emptyList());
properties.forEach((propName, propSchema) -> {
properties.keySet()
.stream()
.sorted()
.forEach(propName -> {
var propSchema = properties.get(propName);
final var paramBuilder = parameterBuilder().in(ParameterIn.QUERY);
paramBuilder.name(propSchema.getName())
.description(propSchema.getDescription())