question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

swagger-ui input text box for body parameters of type string is unusable

See original GitHub issue

Specs

  • Swagger spec version 2.0
  • Swagger-UI docker image swaggerapi/swagger-ui v3.0.5 . a228b9ff44b6

Problem

I have some older endpoints which accept newline delimited strings which I’m trying define in a swagger spec.

The spec looks like this:

post: {
  tags: [
    "NLP"
  ],
  summary: "",
  description: "NLP parse one or more sentences passed in the body of the request",
  operationId: "postNLPParse",
  consumes: [
    "text/plain: charset=utf8"
  ],
  produces: [
    "application/json; charset=utf8"
  ],
  parameters: [
    {
      name: "sentences",
      in: "body",
      description: "Newline delimited sentences",
      required: true,
      schema: {
        type: "string"
      },
    }
  ],
  responses: {
    200: {
      description: "Success",
      schema: {
        $ref: "#/definitions/nlpResponse"
      }
    }
  }
}

Desired solution

Ideally, I would like to be able to edit the string sent as the body in the swagger-ui for testing and demonstration. However the input text box will not allow spaces or newlines and treats the input as if it should be a JSON object ( forces the first character to be a ‘{’ ). screen shot 2017-06-21 at 9 59 50 am Is there anything I can modify in the spec to get around this limitation?

Apologies if this has been addressed somewhere already, I’ve searched for it and can’t find it.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
davidmfreycommented, Jun 21, 2017

I’ll update my swagger-ui to 3.0.14 and try it.

0reactions
shockeycommented, Jun 21, 2017

I see it now, thanks @davidmfrey 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

Swagger integer type cause an error Expected `string` for ...
I found the reason: there should be consumes field defined as text/plain . By default it is application/json . The full code: {...
Read more >
Swagger PUT/POST body value issue
Swagger reports the call to this accepts a parameter of type Workflow . Perfect. Templating from this generates a DTO parameter based function:...
Read more >
Describing Parameters - Swagger
Each parameter has name , value type (for primitive value parameters) or schema (for request body), and optional description . Here is an...
Read more >
Minimal APIs quick reference - Microsoft Learn
Route values; Query string; Header; Body (as JSON); Services provided by dependency injection; Custom. Binding from form values is not natively ...
Read more >
Designing REST API with Open API Specification (OAS) v2.0 ...
The UI opens up editable text area for body & text fields for other applicable parameters like header & query (not shown here...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found