postmanlabs / postman-app-support

Postman is an API platform for building and using APIs. Postman simplifies each step of the API lifecycle and streamlines collaboration so you can create better APIs—faster.
https://www.postman.com
5.84k stars 839 forks source link

Error importing swagger.json from url (working in other importers such as PAW) #2309

Closed tylergoza closed 8 years ago

tylergoza commented 8 years ago
  1. Postman Version: 4.6.3
  2. App (Chrome app or Mac app): Mac app
  3. OS details: OS X 10.11.6
  4. Is the Interceptor on and enabled in the app: yes
  5. Did you encounter this recently, or has this bug always been there: recently first time importing swagger.json
  6. Expected behaviour: import the json as an api call
  7. Console logs (http://blog.getpostman.com/2014/01/27/enabling-chrome-developer-tools-inside-postman/ for the Chrome App, View->Toggle Dev Tools for the Mac app):
 ================================================================
     o
   (/) P O S T M A N
   ^

   Go to View -> Show Postman Console to check your script logs. 

================================================================
requester.js:273947 You are not a member of a team
requester.js:274193 You are not a member of a team
sails.io.js:142 🌏 sync service connectivity initiated
sails.io.js:759 socket replaying queued commands
sails.io.js:142 🌏 connected to sync service.
requester.js:267672 🐶 watchdog checking connection health
2requester.js:261317 Data is not YAML.
requester.js:263683 Uncaught Error Uncaught TypeError: postmanConverters.swagger2_0Converter is not a constructor file:///Applications/Postman.app/Contents/Resources/app/js/requester.js 4267 8 TypeError: postmanConverters.swagger2_0Converter is not a constructor(…)(anonymous function) @ requester.js:263683
requester.js:4267 Uncaught TypeError: postmanConverters.swagger2_0Converter is not a constructor
requester.js:263683 Uncaught Error Uncaught TypeError: postmanConverters.swagger2_0Converter is not a constructor file:///Applications/Postman.app/Contents/Resources/app/js/requester.js 4267 8 TypeError: postmanConverters.swagger2_0Converter is not a constructor(…)(anonymous function) @ requester.js:263683
requester.js:4267 Uncaught TypeError: postmanConverters.swagger2_0Converter is not a constructor
requester.js:263683 Uncaught Error Uncaught TypeError: postmanConverters.swagger2_0Converter is not a constructor file:///Applications/Postman.app/Contents/Resources/app/js/requester.js 4267 8 TypeError: postmanConverters.swagger2_0Converter is not a constructor(…)(anonymous function) @ requester.js:263683
requester.js:4267 Uncaught TypeError: postmanConverters.swagger2_0Converter is not a constructor
requester.js:263683 Uncaught Error Uncaught TypeError: postmanConverters.swagger2_0Converter is not a constructor file:///Applications/Postman.app/Contents/Resources/app/js/requester.js 4267 8 TypeError: postmanConverters.swagger2_0Converter is not a constructor(…)(anonymous function) @ requester.js:263683
requester.js:4267 Uncaught TypeError: postmanConverters.swagger2_0Converter is not a constructor
requester.js:263683 Uncaught Error Uncaught TypeError: postmanConverters.swagger2_0Converter is not a constructor file:///Applications/Postman.app/Contents/Resources/app/js/requester.js 4267 8 TypeError: postmanConverters.swagger2_0Converter is not a constructor(…)(anonymous function) @ requester.js:263683
requester.js:4267 Uncaught TypeError: postmanConverters.swagger2_0Converter is not a constructor
requester.js:261317 Data is not YAML.
sails.io.js:142 🌏 disconnected from sync service. possibly a network outage.
sails.io.js:142 🌏 scheduled reconnection attempt #1 after 14842ms
sails.io.js:142 🌏 reconnecting to sync service. #(1/8)
sails.io.js:142 🌏 reconnected to sync service after being offline for 14.972seconds.
sails.io.js:142 🌏 connected to sync service.
requester.js:267672 🐶 watchdog checking connection health

Attempt to import a swagger.json file from a swagger api server. If this shouldn't work it needs to be noted somewhere in the app that only yaml is supported.

tylergoza commented 8 years ago

Additional information. It doesn't work with yaml as text either.

tylergoza commented 8 years ago

And in case you need it, here is the json:

{"swagger":"2.0","host":"tardis.epb.net:3500","basePath":"/","schemes":["http"],"info":{"title":"Hapi test minions Documentation","version":"0.0.1a-pre"},"securityDefinitions":{"jwt":{"type":"apiKey","name":"authorization","in":"header"}},"security":[{"jwt":[]}],"tags":[],"paths":{"/":{"get":{"summary":"Get allowed calls","operationId":"get","description":"This will return a list of allowed events.","tags":[""],"responses":{"200":{"schema":{"$ref":"#/definitions/Model 1"},"description":"Successful"}}}}},"definitions":{"Model 1":{"type":"array","items":{"type":"string"}}}}
abhijitkane commented 8 years ago

@tylerwgoza This is a regression bug with the latest version of the Mac app - we'll be pushing out a fix soon.

tylergoza commented 8 years ago

@abhijitkane Thanks! I'll pass that along to the team.

vegetableman commented 8 years ago

@tylerwgoza The issue has been fixed in the latest 4.7.0 update.

tylergoza commented 8 years ago

Perfect. Just verified that this is working correctly now. Thanks!

cviebrock commented 8 years ago

It's mostly working. Take the following Swagger document:

{
  "swagger": "2.0",
  "info": {
    "title": "Test"
  },
  "host": "example.com",
  "basePath": "/v1",
  "schemes": [
    "http"
  ],
  "produces": [
    "application/json"
  ],
  "paths": {
    "/accounts/{accountId}/cards/{cardId}": {
      "delete": {
        "summary": "Delete a card associated with an account",
        "parameters": [
          {
            "required": true,
            "name": "accountId",
            "in": "path",
            "description": "The identifier for the account",
            "type": "integer"
          },
          {
            "required": true,
            "name": "cardId",
            "in": "path",
            "description": "The identifier for the card",
            "type": "integer"
          }
        ],
        "responses": {
          "204": {
            "description": "Success"
          }
        }
      }
    }
  }
}

Importing that generates a request with a URL of:

http://example.com/v1/accounts/:accountId/cards/{cardId}

i.e. the first URL parameter, accountId, is correctly interpreted, but the second one, cardId is not.