Skip to content
This repository has been archived by the owner on Aug 29, 2024. It is now read-only.

allow x-example #25

Closed
wants to merge 4 commits into from
Closed

allow x-example #25

wants to merge 4 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Sep 19, 2016

the acutal code is searching for 'example' in the parameters. When using the example field like this...

  /users/{uid}:
    get:
      summary: Returns a user
      operationId: swagger.api.read_user_by_uid
      produces:
        - application/json
      parameters:
        - name: uid
          in: path
          description: UID of user that needs to be fetched
          required: true
          type: string
#          default: myuuid
          example: myuuid
      responses:
        "200":
          description: One User
          schema:
            $ref: "#/definitions/UserRead"

...it fails . The only way to get {uid} populated with 'myuuid' is by using the 'default' property
but it is not intended to be used for setting a default value in such a scenario.

As x-vendor properties are permitted by the spec, let use them:

 /users/{uid}:
    get:
      summary: Returns a user
      operationId: swagger.api.read_user_by_uid
      produces:
        - application/json
      parameters:
        - name: uid
          in: path
          description: UID of user that needs to be fetched
          required: true
          type: string
          x-example: myuuid
      responses:
        "200":
          description: One User
          schema:
            $ref: "#/definitions/UserRead"

@beanqueen
Copy link
Contributor

i don't fully understand the problem, but i'm ok with the solution anyway. the if / if / elif / .. / else should be refactored to be consistent.

@cyprieng
Copy link
Owner

cyprieng commented Sep 20, 2016

I don't see why the 'example' field wouldn't work in your example, neither why x-example would improve this (even if I am completly agree to support it). Can you provide the code that fails ?

@@ -160,6 +160,8 @@ def get_example_from_prop_spec(self, prop_spec):
"""
if 'example' in prop_spec.keys() and self.use_example: # From example
return prop_spec['example']
if 'x-example' in prop_spec.keys() and self.use_example:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change if to elif ?

@beanqueen
Copy link
Contributor

we can close this PR, i added the x-example support and cleaned up the if/elif block

@cyprieng
Copy link
Owner

Done in #26

@cyprieng cyprieng closed this Sep 26, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants