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

Custom requestBody examples not used #4683

Closed
rmlopes opened this issue Jun 29, 2018 · 1 comment
Closed

Custom requestBody examples not used #4683

rmlopes opened this issue Jun 29, 2018 · 1 comment

Comments

@rmlopes
Copy link

rmlopes commented Jun 29, 2018

Q&A

  • OS: [e.g. macOS]
  • Browser: [firefox]
  • Version: [60.0.2]
  • Method of installation: [extension]
  • Swagger-UI version: [e.g. 3.9.1]
  • Swagger/OpenAPI version: [OpenAPI 3.0]

Content & configuration

openapi: 3.0.0
info:
  title:
  description: Model training and querying utilities.
  contact:
    name: 
  license:
    name: BSD
  version: '0.1'
servers:
  - url: 'https://localhost:5000'
paths:
  /people:
    get:
      summary: Retrieves one or more people
      responses:
        '200':
          description: An array of people
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/People'
        default:
          $ref: '#/components/responses/error'
      parameters:
        - null
      tags:
        - People
    post:
      summary: Stores one or more people
      requestBody:
        $ref: '#/components/requestBodies/People'
      responses:
        '201':
          description: operation has been successful
        default:
          $ref: '#/components/responses/error'
      parameters:
        - null
      tags:
        - People
    delete:
      summary: Deletes all people
      responses:
        '204':
          description: operation has been successful
        default:
          $ref: '#/components/responses/error'
      parameters:
        - null
      tags:
        - People
  '/people/{peopleId}':
    get:
      summary: Retrieves a People document
      responses:
        '200':
          description: People document fetched successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/People'
        default:
          $ref: '#/components/responses/error'
      parameters:
        - $ref: '#/components/parameters/People__id'
        - null
      tags:
        - People
    put:
      summary: Replaces a People document
      responses:
        '200':
          description: People document replaced successfully
        default:
          $ref: '#/components/responses/error'
      requestBody:
        $ref: '#/components/requestBodies/People'
      parameters:
        - $ref: '#/components/parameters/People__id'
        - $ref: '#/components/parameters/ifMatch'
        - null
      tags:
        - People
    patch:
      summary: Updates a People document
      responses:
        '200':
          description: People document updated successfully
        default:
          $ref: '#/components/responses/error'
      requestBody:
        $ref: '#/components/requestBodies/People'
      parameters:
        - $ref: '#/components/parameters/People__id'
        - $ref: '#/components/parameters/ifMatch'
        - null
      tags:
        - People
    delete:
      summary: Deletes a People document
      responses:
        '204':
          description: People document deleted successfully
        default:
          $ref: '#/components/responses/error'
      parameters:
        - $ref: '#/components/parameters/People__id'
        - $ref: '#/components/parameters/ifMatch'
        - null
      tags:
        - People
  '/people/{peopleId}/related':
    get:
      summary: 'Retrieves one or more people/{peopleId}/related'
      responses:
        '200':
          description: 'An array of people/{peopleId}/related'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Sub_resource'
        default:
          $ref: '#/components/responses/error'
      parameters:
        - $ref: '#/components/parameters/People__id'
      tags:
        - Sub_resource
    post:
      summary: 'Stores one or more people/{peopleId}/related'
      requestBody:
        $ref: '#/components/requestBodies/Sub_resource'
      responses:
        '201':
          description: operation has been successful
        default:
          $ref: '#/components/responses/error'
      parameters:
        - $ref: '#/components/parameters/People__id'
      tags:
        - Sub_resource
    delete:
      summary: 'Deletes all people/{peopleId}/related'
      responses:
        '204':
          description: operation has been successful
        default:
          $ref: '#/components/responses/error'
      parameters:
        - $ref: '#/components/parameters/People__id'
      tags:
        - Sub_resource
  '/people/{peopleId}/related/{sub_resourceId}':
    get:
      summary: Retrieves a Sub_resource document
      responses:
        '200':
          description: Sub_resource document fetched successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Sub_resource'
        default:
          $ref: '#/components/responses/error'
      parameters:
        - $ref: '#/components/parameters/Sub_resource__id'
        - $ref: '#/components/parameters/People__id'
      tags:
        - Sub_resource
    put:
      summary: Replaces a Sub_resource document
      responses:
        '200':
          description: Sub_resource document replaced successfully
        default:
          $ref: '#/components/responses/error'
      requestBody:
        $ref: '#/components/requestBodies/Sub_resource'
      parameters:
        - $ref: '#/components/parameters/Sub_resource__id'
        - $ref: '#/components/parameters/ifMatch'
        - $ref: '#/components/parameters/People__id'
      tags:
        - Sub_resource
    patch:
      summary: Updates a Sub_resource document
      responses:
        '200':
          description: Sub_resource document updated successfully
        default:
          $ref: '#/components/responses/error'
      requestBody:
        $ref: '#/components/requestBodies/Sub_resource'
      parameters:
        - $ref: '#/components/parameters/Sub_resource__id'
        - $ref: '#/components/parameters/ifMatch'
        - $ref: '#/components/parameters/People__id'
      tags:
        - Sub_resource
    delete:
      summary: Deletes a Sub_resource document
      responses:
        '204':
          description: Sub_resource document deleted successfully
        default:
          $ref: '#/components/responses/error'
      parameters:
        - $ref: '#/components/parameters/Sub_resource__id'
        - $ref: '#/components/parameters/ifMatch'
        - $ref: '#/components/parameters/People__id'
      tags:
        - Sub_resource
components:
  schemas:
    People:
      type: object
      properties:
        name:
          description: the last name of the person
          example: Doe
          type: string
        job:
          $ref: '#/components/schemas/People_job'
        email:
          pattern: ^.+@.+$
          type: string
        position:
          readOnly: true
          type: string
        relations:
          type: array
          items:
            type: object
            properties:
              relation_type:
                type: string
              relation:
                $ref: '#/components/schemas/People__id'
            required:
              - relation_type
        location:
          type: object
          properties:
            type:
              enum:
                - Point
              type: string
            coordinates:
              minItems: 2
              maxItems: 2
              type: array
              items:
                type: integer
          required:
            - type
            - coordinates
        _id:
          $ref: '#/components/schemas/People__id'
      required:
        - name
        - job
        - email
      description: the people resource
    Sub_resource:
      type: object
      properties:
        peopleId:
          $ref: '#/components/schemas/People__id'
        subject:
          type: string
        _id:
          type: string
          format: objectid
      description: A sub resource to test regex urls.
    People__id:
      type: string
      format: objectid
    People_job:
      description: the job of the person
      type: string
    Error:
      type: object
      properties:
        _status:
          type: integer
        _error:
          type: object
          properties:
            code:
              type: integer
            message:
              type: string
      required:
        - _status
        - _error
  responses:
    error:
      description: An error message
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  parameters:
    People__id:
      in: path
      name: peopleId
      required: true
      description: ''
      example: ''
      schema:
        type: string
    Sub_resource__id:
      in: path
      name: sub_resourceId
      required: true
      description: ''
      example: ''
      schema:
        type: string
    ifMatch:
      in: header
      name: If-Match
      description: Current value of the _etag field
      required: true
      schema:
        type: string
  examples:
    People:
      summary: 'An example {0} document.'
      description: >-
        An example for People documents request
        bodies.                             Used in POST, PUT, PATCH methods.
    Sub_resource:
      summary: 'An example {0} document.'
      description: >-
        An example for Sub_resource documents request
        bodies.                             Used in POST, PUT, PATCH methods.
      value:
        subject: A note from some person.
  requestBodies:
    People:
      description: A People or list of People documents
      required: true
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/People'
          examples:
            People:
              $ref: '#/components/examples/People'
    Sub_resource:
      description: A Sub_resource document.
      required: true
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Sub_resource'
          examples:
            Sub_resource:
              $ref: '#/components/examples/Sub_resource'
  securitySchemes:
    oAuth2:
      type: oauth2
      description: >-
        This API uses OAuth 2 with the implicit grant flow. [More
        info](https://api.example.com/docs/auth)
      flows:
        password:
          tokenUrl: 'https://localhost:5000/oauth/token'
          scopes: {}
security:
  - oAuth2: []
tags:
  - name: People
    description: the people resource
  - name: Sub_resource
    description: A sub resource to test regex urls.

Describe the bug you're encountering

The Sub_resource should show the custom resource example in the 'Example Value' of the requestBody, instead it always shows the example built from the schema property. This is visible as well in Swagger Editor.

@hkosova
Copy link
Contributor

hkosova commented Jun 29, 2018

Thanks for the report! This issue is being tracked in #3437.

@shockey shockey closed this as completed Jul 18, 2018
@lock lock bot locked and limited conversation to collaborators Jul 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants