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

Provide a way to not auto-fill examples for certain parameters #686

Closed
majoshi1 opened this issue Mar 8, 2022 · 5 comments
Closed

Provide a way to not auto-fill examples for certain parameters #686

majoshi1 opened this issue Mar 8, 2022 · 5 comments

Comments

@majoshi1
Copy link

majoshi1 commented Mar 8, 2022

We have some optional fields with examples. But, they still getting populated with first value from examples. The default can be set only inside examples. But, that also shows up in examples. So, is it possible to allow setting default outside?
Current: To show empty default for non-required fields.

{
	"parameters": [{
			"name": "someName",
			"required": false,
			"schema": {},
			"examples": {
				"default": false,
				"example1": {
					"summary": "Item1",
					"value": "10"
				}
			}
		}
	]
}

Proposed: Set default inside schema, so that it does not appear in examples.

{
	"parameters": [{
			"name": "someName",
			"required": false,
			"schema": {
				"default": false
			},				
			"examples": {
				"example1": {
					"summary": "Item1",
					"value": "10"
				}
			}
		}
	]
}
@mrin9
Copy link
Collaborator

mrin9 commented Mar 9, 2022

I am not sure whats the ask here. Can you explain with some screen shot may be, what are you getting and what do you intent to have

@majoshi1
Copy link
Author

majoshi1 commented Mar 9, 2022

Sorry for any confusion. This is actually a defect that optional fields are pre-populated with first value from examples. Can provide example if needed.

@hrvoj3e
Copy link

hrvoj3e commented Mar 15, 2022

I have the same problem.

I would like to somehow hint in yaml schema that field should not be populated from example.
Examples are great and I can click on them to populate field with defaults.
Maybe some extension field x-example-fill: false or something?

get:
  summary: content search
  operationId: seachContent
  tags:
    - content-search
  parameters:
    - in: query
      name: search
      examples:
        a:
          value: my example 1
        b:
          value: "*"
      schema:
        type: string
      description: term to search (use "*" to show all)
    - in: query
      name: id
      example: my-id
      schema:
        type: string
    - in: query
      name: db
      example: ccc
      schema:
        type: string
        enum:
         - aaa
         - bbb
         - ccc
         - ddd
  responses:
    200:
      description: OK
      content:
        application/json: {}
    400:
      $ref: "../response/400.yaml"

image

@mrin9
Copy link
Collaborator

mrin9 commented Mar 22, 2022

Maybe some extension field x-example-fill: false or something?

I think thats a good suggestion.
added to our queue

@mrin9 mrin9 changed the title Allow setting default outside examples Provide a way to not auto-fill examples for certain parameters Mar 22, 2022
@mrin9 mrin9 closed this as completed in 4397b35 Mar 26, 2022
@mrin9
Copy link
Collaborator

mrin9 commented Mar 26, 2022

use vendor extension x-example-fill : no for each parameter to indicate if it should be filled
you may also use RapiDoc attribute fill-request-fields-with-example = true/false to indicate no autofilling of example for the entire spec

get:
  summary: content search
  operationId: seachContent
  tags:
    - content-search
  parameters:
    - in: query
      name: search
      example: 'my-search-string'
      x-fill-example:  no    # <--- vendor extension
      schema:
        type: string
      description: term to search (use "*" to show all)
    - in: query
      name: id
      example: my-id
      schema:
        type: string

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

No branches or pull requests

3 participants