Skip to content

Order of examples is (sometimes) not preserved #3012

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
michaldo opened this issue May 28, 2025 · 0 comments
Open

Order of examples is (sometimes) not preserved #3012

michaldo opened this issue May 28, 2025 · 0 comments

Comments

@michaldo
Copy link

Order of examples is sometimes not preserved:

import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
@RestController
public class SpringdocExampleOrderApplication {

    public static void main(String[] args) {
        SpringApplication.run(SpringdocExampleOrderApplication.class, args);
    }

    @GetMapping
    @io.swagger.v3.oas.annotations.Parameter(
            in = ParameterIn.HEADER,
            name = "x-header",
            examples = {
                    @ExampleObject(value = "AAA", name = "First"),
                    @ExampleObject(value = "BBB", name = "Second")
            })
    void nope() {}
}

Image

{
  "openapi": "3.1.0",
  "info": {
    "title": "OpenAPI definition",
    "version": "v0"
  },
  "servers": [
    {
      "url": "http://localhost:8080",
      "description": "Generated server url"
    }
  ],
  "paths": {
    "/": {
      "get": {
        "tags": [
          "springdoc-example-order-application"
        ],
        "operationId": "nope",
        "parameters": [
          {
            "name": "x-header",
            "in": "header",
            "examples": {
              "Second": {
                "description": "Second",
                "value": "BBB"
              },
              "First": {
                "description": "First",
                "value": "AAA"
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  },
  "components": {

  }
}

If 'First' -> '1', 'Second' -> '1' order is preserved
Springdoc 2.8.8, Spring Boot 3.4.5

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