Skip to content

Order of required properties #4887

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

Open
marceloverdijk opened this issue May 13, 2025 · 0 comments
Open

Order of required properties #4887

marceloverdijk opened this issue May 13, 2025 · 0 comments

Comments

@marceloverdijk
Copy link

https://github.com/swagger-api/swagger-core/blame/f728c95fd8d6d9153cdcc18043a15bd6ae0612e3/modules/swagger-models/src/main/java/io/swagger/v3/oas/models/media/Schema.java#L1211

For documentation readability it would be very convenient if the required properties of schema are the same of the order of properties in the schema itself. Unfortunately this is not the case and the required properties are always ordered alphabetically.

    public void setRequired(List<String> required) {
        List<String> list = new ArrayList<>();
        if (required != null) {
            for (String req : required) {
                if (this.properties == null || this.properties.containsKey(req)) {
                    list.add(req);
                }
            }
        }
        Collections.sort(list); // <==================== HERE!
        if (list.isEmpty()) {
            list = null;
        }
        this.required = list;
    }

What is the rationale behind this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant