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

Swagger Not allowed Values error on required definition #2103

Closed
PetroGromovo opened this issue Feb 16, 2020 · 2 comments
Closed

Swagger Not allowed Values error on required definition #2103

PetroGromovo opened this issue Feb 16, 2020 · 2 comments

Comments

@PetroGromovo
Copy link

Hello,
I registered at swagger and created new app (api 3 version)
/tasks path has 2 not required fields and I can not set it not required,
it shows Not allowed Values error...

I have :


  openapi: 3.0.0
    info:
      description: A Simple IP Address API
      title: VTasks
      version: v1
    servers:
    # Added by API Auto Mocking Plugin
      - description: SwaggerHub API Auto Mocking
        url: https://virtserver.swaggerhub.com/petrogromovo/Vtasks/1.0.0
      - description: SwaggerHub API Auto Mocking
        url: http://hosting.tk
    #  host: hosting.tk
    # schemes:
    #  - http
    # basePath: /
    
    
    paths:
              
      /tasks:
        get:
          tags:
            - tasks
          summary: Get paginated / filtered tasks listing
          operationId: tasks
          parameters:
            - name: page
              in: path
              description: The page number to be fetched. If missed default 1.
              required: true
              schema:
                type: integer
            - name: order_by
              in: path
              description: The order_by  be fetched. 
              required: false  // ERROR : should be equal to one of the allowed values allowedValues: true
              schema:
                type: string
            - name: filter
              in: path
              description: The filter for title field. 
              required: false // ERROR : should be equal to one of the allowed values allowedValues: true
              schema:
                type: string
          responses:
            '200':
              description: successful operation
            '400':
              description: Invalid tasks supplied
            '404':
              description: tasks were not found

But if to remove these required definitions, I got 2 errors :

should have required property 'required' missingProperty: required
Which is valid syntax ?

Thanks!

@hkosova
Copy link
Contributor

hkosova commented Feb 16, 2020

Are these parameters supposed to be path parameters or query parameters?

Path parameters (in: path) are part of the endpoint path, and as such must be indicated by {...} in the path template:

paths:
  /tasks/{page}/{order_by}/{filter}:

Path parameters are always required, i.e. they must have required: true.

Query parameters are send in the query string, e.g. /tasks?page=...&order_by=.... To use query parameters, change the parameter location to in: query.

Please see Describing Parameters to learn more about the parameter syntax.

@PetroGromovo
Copy link
Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants