luckymarmot / Paw-SwaggerImporter

Swagger/OpenAPI 2.0 Importer for Paw
https://paw.cloud/extensions/SwaggerImporter
MIT License
38 stars 10 forks source link

definition references not correctly parsed #24

Closed klh closed 8 years ago

klh commented 8 years ago

when using swagger references such as:

post:
      tags:
        - Shared
      operationId: CallGeneric_PostInternal
      consumes:
        - application/json
        - text/json
        - application/xml
        - text/xml
        - application/x-www-form-urlencoded
      produces:
        - application/json
        - text/json
        - application/xml
        - text/xml
        - text/javascript
        - application/javascript
        - application/json-p
      parameters:
        - name: url
          in: path
          required: true
          type: string
        - name: payload
          in: body
          required: true
          schema:
            $ref: '#/definitions/System.Object'
      responses:
        '200':
          description: OK
          schema:
            $ref: '#/definitions/System.Object'
      deprecated: false

see $ref: '#/definitions/System.Object' that links to:

definitions:
  someapi.Endpoints.Apps.Authentication.AuthenticationRequest:
    required: ['']
    type: object
    properties:
      userName:
        type: string
      password:
        type: string
  System.Object:
    required: ['']
    type: object
    properties: {}

is not correctly rendered as object {username:'',password:''}

JonathanMontane commented 8 years ago

I'm not exactly sure what the issue is here.

If you navigate to #/definitions/System.Object, you'll obtain the following JSON Schema:

{
  required: ['']
  type: 'object',
  properties: {}
}

which would be rendered as a JSON Schema Faker Dynamic Value (JSF), with the generated value {}.

If you want to have a required username and password, you should edit the JSON Schema to look like

definitions:
  ...
  System.Object:
    required: [ 'username', 'password' ]
    type: object
    properties:
      username:
        type: string
      password:
        type: string
JonathanMontane commented 8 years ago

@klh Do you still have any issues with importing swagger files into Paw ?

lumaxis commented 8 years ago

@JonathanMontane I'm not sure if I'm encountering the exact same issue but for me, the imported Swagger definitions look like this:

screenshot 2016-08-25 02 34 58

What information can I give you to help debug this? A sample definition looks like this:

ErrorResponse:
  type: object
  properties:
    error:
      $ref: "#/definitions/Error"
  required:
    - error
JonathanMontane commented 8 years ago

Probably found the bug, I'm looking into fixing it right now.

JonathanMontane commented 8 years ago

fixed.