Skip to content

Parameters with examples have Unexpected UI Behavior #820

@JoshRosenstein

Description

@JoshRosenstein

See below screenshot when using pr_set_api_spec, to add Examples.

Within the resulting openapi.json you can see that all the examples are duplicated within the example node for some reason and im guessing that is causing the issue in the UI.

Expected:
image

Recieved:
image

Reproduce

pr <- pr() %>% 
  pr_get(path = "/health-check",
         handler = function(msg) {
           msg
         }) %>%
  pr_set_api_spec('./openapi.yaml') %>% pr_run()

openapi.yaml

openapi: 3.0.3
info:
  title: Test Examples
  description: API Description
  version: 0.0.0

paths:
  /health-check:
    get:
      summary: " Determine if the API is running and listening as expected"
      responses:
        default:
          description: Default response.
    parameters:
      - in: query
        name: msg
        schema:
          type: string
        examples: # Multiple examples
          one:
            value: Hello
            summary: Say Hello
          two:
            value: Goodbye
            summary: Say Goodbye

Resulting openapi.json

{
   "servers":[
      {
         "url":""
      }
   ],
   "openapi":"3.0.3",
   "info":{
      "title":"Test Examples",
      "description":"API Description",
      "version":"0.0.0"
   },
   "paths":{
      "/health-check":{
         "get":{
            "summary":" Determine if the API is running and listening as expected",
            "responses":{
               "default":{
                  "description":"Default response."
               }
            }
         },
         "parameters":[
            {
               "in":"query",
               "name":"msg",
               "schema":{
                  "type":"string"
               },
               "examples":{
                  "one":{
                     "value":"Hello",
                     "summary":"Say Hello"
                  },
                  "two":{
                     "value":"Goodbye",
                     "summary":"Say Goodbye"
                  }
               },
               "example":{
                  "one":{
                     "value":"Hello",
                     "summary":"Say Hello"
                  },
                  "two":{
                     "value":"Goodbye",
                     "summary":"Say Goodbye"
                  }
               }
            }
         ]
      }
   }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions