Skip to content
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

Date Without Example Rendered with Pattern as Example #10279

Open
JinHo3ds opened this issue Feb 9, 2025 · 0 comments
Open

Date Without Example Rendered with Pattern as Example #10279

JinHo3ds opened this issue Feb 9, 2025 · 0 comments

Comments

@JinHo3ds
Copy link

JinHo3ds commented Feb 9, 2025

Q&A (please complete the following information)

  • OS: Windows
  • Browser: Chrome
  • Method of installation: spring-doc
  • Swagger-UI version: 5.18.2
  • Swagger/OpenAPI version: Swagger 2.2.28, OpenAPI 3.1.0

Content & configuration

The pattern for date-time is populated as the example instead of the current date-time in the previous OpenAPI version.

Example Swagger/OpenAPI definition:

{
  "openapi": "3.1.0",
  "info": {
    "title": "OpenAPI definition",
    "version": "v0"
  },
  "servers": [
    {
      "url": "http://localhost:8080",
      "description": "Generated server url"
    }
  ],
  "tags": [
    {
      "name": "Dummy",
      "description": "Dummy Controller"
    }
  ],
  "paths": {
    "/dummy/execute": {
      "post": {
        "tags": [
          "Dummy"
        ],
        "operationId": "run",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DummyDTO"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "*/*": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "DummyDTO": {
        "type": "object",
        "properties": {
          "dummyDate": {
            "type": "string",
            "format": "date-time",
            "description": "Some Dummy Date",
            "pattern": "Some Pattern Here"
          }
        }
      }
    }
  }
}

Describe the bug you're encountering

It is expected that the current date-time is populated as the example.

Expected behavior

{
  "openapi": "3.0.1",
  "info": {
    "title": "OpenAPI definition",
    "version": "v0"
  },
  "servers": [
    {
      "url": "http://localhost:8080",
      "description": "Generated server url"
    }
  ],
  "tags": [
    {
      "name": "Dummy",
      "description": "Dummy Controller"
    }
  ],
  "paths": {
    "/dummy/execute": {
      "post": {
        "tags": [
          "Dummy"
        ],
        "operationId": "run",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DummyDTO"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "*/*": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "DummyDTO": {
        "type": "object",
        "properties": {
          "dummyDate": {
            "pattern": "Some Pattern Here",
            "type": "string",
            "description": "Some Dummy Date",
            "format": "date-time"
          }
        }
      }
    }
  }
}

Example with 3.0.1

Image

Screenshots

Example with 3.1.0

Image

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