Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameters with examples have Unexpected UI Behavior #820

Closed
JoshRosenstein opened this issue Aug 20, 2021 · 0 comments · Fixed by #861
Closed

Parameters with examples have Unexpected UI Behavior #820

JoshRosenstein opened this issue Aug 20, 2021 · 0 comments · Fixed by #861

Comments

@JoshRosenstein
Copy link

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"
                  }
               }
            }
         ]
      }
   }
}
meztez added a commit to meztez/plumber that referenced this issue Aug 20, 2021
@meztez meztez mentioned this issue Aug 20, 2021
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant