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

PROPOSAL: Partial Parameters Definition / Override parameters values #718

Closed
oliverhr opened this issue Jun 23, 2016 · 2 comments
Closed

Comments

@oliverhr
Copy link

oliverhr commented Jun 23, 2016

The PARAMETERS DEFINITIONS OBJECT should accept partial definition for parameters or properties overriding:

Currently supported:

...
  /recipe:
    post:
      operationId: recipe_new

      parameters:
        - name: id
          in: query
          description: Recipe ID
          required: true
          type: string
        - name: ingredients
          in: query
          description: list of ingredients
          type: array
          items:
            type: string
          collectionFormat: csv
        - $ref: "#/parameters/FoodType"

      responses:
        default:
          description: Error
          schema:
            $ref: "#/definitions/ErrorResponse"
        200:
          description: Success
          schema:
            $ref: "#/definitions/SuccessResponse"


# ---------------------------------------------------
definitions:

  SuccessResponse:
    properties:
      message:
        type: string

  ErrorResponse:
    required:
      - message
    properties:
      message:
        type: string
# ---------------------------------------------------
parameters:

  FoodType:
    name: foodType
    description: Type of food on the recipe
    required: true
    in: formData
    type: string
    default: cake
    enum:
      - cake
      - cookies
      - bread

As you can see on the endpoint definition we add FoodType as reference, but we are forced tu use all the defined properties.

It would be good if we could define a partial definition or override something like this:

...
# ---------------------------------------------------
parameters:

  FoodType:
    name: foodType
    description: Type of food on the recipe
    required: true
    type: string
    default: cake
    enum:
      - cake
      - cookies
      - bread

And use like this:

  /recipe:
    post:
      operationId: recipe_new

      parameters:
        - name: id
          in: query
          description: Recipe ID
          required: true
          type: string
        - name: ingredients
          in: query
          description: list of ingredients
          type: array
          items:
            type: string
          collectionFormat: csv
        - $ref: "#/parameters/FoodType"
          in: query
          required: false
...

I defined required as true but later I override this value to false, and in is defined on the endpoint only.

@ePaul
Copy link
Contributor

ePaul commented Jun 23, 2016

Generally $ref doesn't work together with other properties in a JSON object. If this were to be changed, this should be done for all the places where $ref is used.

Some related issues: #926, #648, #674, #556.

@fehguy
Copy link
Contributor

fehguy commented Jun 23, 2016

yes, supporting that would break all support for JSON pointers, which we really don't want to do.

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