Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Order of examples is (sometimes) not preserved #3012

@michaldo

Description

@michaldo

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions