RapiPdf icon indicating copy to clipboard operation
RapiPdf copied to clipboard

Examples missing?

Open StephenTallamy opened this issue 5 years ago • 10 comments

When rendering out the PDF I seem to only get the model data from my OpenAPI v3 document. I'm not seeing the examples. Any reason why no examples shown?

StephenTallamy avatar Aug 09 '19 16:08 StephenTallamy

the only reason is that we couldn't reach any consensus within our team to implement it and the way to display it.

Are you looking for curl command, code snippet or just some sample values based on data-types ? If you can provide me some samples (pdfs/word doc) based on your needs covering most possible data-types and scenarios then I can re-open this discussion

mrin9 avatar Aug 29 '19 15:08 mrin9

Let's say we have the following schema defined:

components:
    schemas:
        rider:
            type: object
            description: A registered rider.
            properties:
                id:
                    type: integer
                    format: int64
                    description: The external rider id.
                    example: 12345
                lastName:
                    type: string
                    example: Pan
                firstName:
                    type: string
                    example: Peter
            required:
                - id
                - lastName
            example:
                id: 12345
                lastName: Pan

It would be helpful to show the example for each individual property as well as the example for the entire schema. Note that the example for the schema might not include non-required properties.

HolisticDeveloper avatar Nov 21 '19 19:11 HolisticDeveloper

We added examples in our roadmap, and it will work exactly the way you explained above. The issues that we face now is, some spec even without any example can generate 1000 pages, including example would almost double that number and may create memory overflows.

We may introduce this feature behind a property or also thinking of making it cli based. Expect some traction on this in Q1 of 2020

mrin9 avatar Nov 22 '19 16:11 mrin9

Is it possible to add a template parameter to control whether examples are included or not? E.g.

<template>
  {
    "includeExamples"          : "true",
}
 </template>

shenghu avatar Jan 18 '20 06:01 shenghu

In release 2.1.1 use include-example attribute to include examples in the generated PDF. As of now this feature is limited to Request parameters. Request body and Response Body examples will follow later

mrin9 avatar Feb 16 '20 06:02 mrin9

Request body and Response Body examples will follow later

When will this be? We would need this feature.

pme123 avatar Mar 20 '20 08:03 pme123

This is a big feature as there are certain complex scenarios on how examples can be specified in an OpenAPI spec.

Currently we are rolling various example support in RapiDoc

we are going to wait, collect feedback, and stabilize it further if needed. Only after that we are going to add example feature in RapiPDF

mrin9 avatar Mar 27 '20 19:03 mrin9

Please see PR https://github.com/mrin9/RapiPdf/pull/68

DaManDOH avatar Jul 25 '20 14:07 DaManDOH

Been two years since PR addressing this issue was accepted. Should this issue still be open?

DaManDOH avatar Sep 21 '22 14:09 DaManDOH

The latest code doesn't seem to render the examples correctly.

For an OpenApi v3.0 JSON schema, only the top level node is printed for all examples. https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/examples/v3.0/api-with-examples.json

For an OpenApi v2 JSON schema, "response" is printed for all examples. https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/examples/v2.0/json/api-with-examples.json

icnocop avatar Mar 11 '23 05:03 icnocop