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

String example for RequestBody is wrongly reported with double quotes in the UI #10035

Open
marco-brandizi opened this issue Jun 19, 2024 · 0 comments

Comments

@marco-brandizi
Copy link

Q&A (please complete the following information)

  • OS: macOS 14.5 (23F79
  • Browser: Chrome 126.0.6478.61
  • Version: [e.g. 22]
  • Method of installation: [e.g. npm, dist assets]
  • Swagger-UI version: 5.2.0 (via Spring Boot)
  • Swagger/OpenAPI version: Swagger 2.2.22, OpenAPI 3.0.1

Content & configuration

Example Swagger/OpenAPI definition:

...
    "/v1/search-stats": {
      "post": {
        "summary": "Various stats about keyword-search",
        "description": "\tEstimates how many items (matched documents, non matched docs) a search string\n\twould return from the /search API.\n",
        "operationId": "keywordSearchStats",
        "requestBody": {
          "description": "The same as keywords in /search",
          "content": {
            "application/json": {
              "schema": {
                "type": "string",
                "example": "'seed germination' OR flower*"
              }
            }
          }
        },
...        

Describe the bug you're encountering

When using the definitions above (coming from Swagger annotations), the Swagger UI includes double quotes in the displayed example, when you try the API with a literal value of: "'seed germination' OR flower*", the result is null, since the implementation expects to receive a string without double quotes: 'seed germination' OR flower*.

To reproduce...

Use @io.swagger.v3.oas.annotations.parameters.RequestBody in a Spring REST controller's method that accept a simple String as request body, then check the results in the Spring-generated Swagger UI.

Expected behavior

Double quotes should only be included when the example specify them, not automatically, as it seems to be the case.

Additional context or thoughts

Looks similar to #4643

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