swagger-api / swagger-api/swagger-ui

Swagger interface refuses to 'try' text value 1.0 as examplevalue in TextPlain

Open
#7,721 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

Describe the bug

@Path( "" )
public interface RestResource {

    @POST
    @Path( "/reproduce" )
    @Consumes( MediaType.TEXT_PLAIN  )
    @Produces( MediaType.TEXT_PLAIN )
    @Operation(
        operationId = "test",
        summary = "this is a tester",
        description = "a long story for something short: test"
    )
    @RequestBody(
        content = @Content(
            mediaType = MediaType.TEXT_PLAIN,
            examples = {
                @ExampleObject(
                    name = "version",
                    description = "1.0",
                    value = "1.0"
                )
            }
        )
    )
    @APIResponse(
        responseCode = "200",
        content = @Content( mediaType = MediaType.TEXT_PLAIN),
        description = "The result."
    )
    Response test(String xml);
}

Gives result

image

Expected behavior

an example value 1.0

Actual behavior

1. Apparently some string manipulation takes place in the translation to javascript.

How to Reproduce?

See reproducer: https://github.com/sjaakd/reproducer_quarkus_swagger_1_0

Try:
http://localhost:8080/reproducer/q/swagger-ui/#/Rest%20Resource/test

Output of uname -a or ver

No response

Output of java -version

11

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.4.2.Final

Build tool (ie. output of mvnw --version or gradlew --version)

maven

Additional information

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue through the Swagger UI entry point at /reproducer/q/swagger-ui/#/Rest%20Resource/test using the linked Quarkus reproducer. Trace how the TEXT_PLAIN example value moves into the Try flow, then verify that the displayed and submitted example remains 1.0 rather than 1.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, openapi
Domain
api, frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.