GithubHelp home page GithubHelp logo

Comments (5)

ozscheyge avatar ozscheyge commented on July 20, 2024

Afaics, we are rendering correct OpenAPI 2, but redoc would like to have the yaml example string in a certain format/syntax?

from restdocs-api-spec.

arhohuttunen avatar arhohuttunen commented on July 20, 2024

I seem to have forgotten to answer to this. The problem is not that the example has wrong string format, but that it is a string, since using |- denotes a string.

examples:
  application/json: |-
    {
      "foo": "bar"
    }

This cannot be rendered as an object, since it’s not. It is a string representation of the object we need.

The correct way to represent the example would be to use an actual object:

examples:
  application/json:
    {
      ”foo”: ”bar”
    }

Reference: https://swagger.io/docs/specification/2-0/adding-examples/

The same happens with JSON output as well, because the example is wrapped in quotes. What we ended up doing to work around this was to parse the output ourselves to get rid of the extra characters in examples.

from restdocs-api-spec.

kiftio avatar kiftio commented on July 20, 2024

Fyi - after upgrading to spring boot 2.3.x, and transitively to jackson 2.11.0, this is now a bit tricker to work around.

Where we used to get this output:

  |-
  {
      "a":"b",
      "c":"d"
  }

We now get:

"{\n    \"a\":\"b\",\n    \"c\":\"d\"\n}"

So it's no longer just a case of removing |- to get redoc to display unquoted request / response samples.

I think it's potentially due to this change - FasterXML/jackson-dataformats-text@c41a621#diff-6eedc03a68a69933c763e674f2d7c42f

from restdocs-api-spec.

thugcee avatar thugcee commented on July 20, 2024

So it's no longer just a case of removing |- to get redoc to display unquoted request / response samples.

Try this workaround: #109 (comment)

from restdocs-api-spec.

ozscheyge avatar ozscheyge commented on July 20, 2024

Based on kiftio's findings and https://yaml.org/spec/1.2/spec.html#id2788859, I'd say: quoting of the example is working as intended by YAML spec and I'd close this.

thugcee provided a nice workaround for redoc users.

from restdocs-api-spec.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.