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.

Example request string is not populated

See original GitHub issue

Trying to migrate from swagger-ui 2x to 3.0.12. It seems that swagger-ui 3.x is not able to render x-examples data.

"/data/targets" : { "post" : { "tags" : [ "dummy" ], "summary" : "Returns validation results of given list of targets.", "description" : "", "operationId" : "dataTargets", "produces" : [ "application/json" ], "parameters" : [ { "in" : "body", "name" : "body", "description" : "Targets list in JSON format.", "required" : true, "schema" : { "type" : "string" }, "x-examples" : { "default" : "{\"targets\": \"[1, 2, 3, 4]\"}" } } <...> }

In version 2.x swagger-ui was able to use the value from x-examples as example request. As a quick and dirty hack, I have made some changes in src/core/components/param-body.jsx

updateValues = (props) => { let { specSelectors, pathMethod, param, isExecute, consumesValue="" } = props let parameter = specSelectors ? specSelectors.getParameter(pathMethod, param.get("name")) : {} let isXml = /xml/i.test(consumesValue); let paramValue = isXml ? parameter.get("value_xml") : parameter.get("value"); if (parameter.get("x-examples") && parameter.get("x-examples").get("default")) { paramValue = parameter.get("x-examples").get("default") } .... }

Is it possible to address this properly? Add support of x-examples into core or maybe create a plugin for this?

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
heldersepucommented, Oct 26, 2017

@gmartinezsan Do you still have the problem? Can you send us your swagger.json?

0reactions
hkosovacommented, Mar 24, 2021

By the way, OpenAPI 3 has built-in support for request body examples. You can provide one or multiple examples and also reference external examples.

openapi: 3.0.0

paths:
  /something:
    post:
      requestBody:
        content:
          application/json:
            schema:
              type: object
            example:   # <------
              targets: [1, 2, 3, 4]
Read more comments on GitHub >

github_iconTop Results From Across the Web

HttpServletRequest - Get query string parameters, no form data
I wrote below code to get query string parameters. Using apache StringUtils and ArrayUtils which supports CSV separated query param values as well....
Read more >
How to set default query string parameter value for webapi?
The name parameter needs to have a default value, if I use string name = "world", it seems not working and throw
Read more >
Auto-populate form fields with a query string - Knowledge Base
Learn how to auto-populate field values in a form on a page by adding query strings to the page URL.
Read more >
Passing Information via Query Strings - Qualtrics
You can pass multiple values for the same field within a query string. The result will be a combined field in your response...
Read more >
Request and response objects - Django documentation
A string representing the full path to the requested page, not including the scheme, ... For example, if the WSGIScriptAlias for your application...
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