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

ValueError: swagger.yaml is not a valid swagger2.0 file: expected string or buffer #56

Open
ptman opened this issue Nov 7, 2017 · 5 comments

Comments

@ptman
Copy link

ptman commented Nov 7, 2017

I'm trying to parse a swagger file:

from swagger_parser import SwaggerParser
p = SwaggerParser(swagger_path='swagger.yaml')

The same file is valid in editor.swagger.io and http://bigstickcarpet.com/swagger-parser/www/index.html

I'd like at least a line number or similar to better understand the error.

@robertlagrant
Copy link

I have the same issue. Even with minimal swagger, such as:

swagger: "2.0"
info:
  description: "This is a sample server Petstore server."
  version: "1.0.0"
  title: "Swagger Petstore"
schemes:
- "http"
paths:
  /pet:
    post:
      operationId: "addPet"
      parameters:
      - in: "body"
        name: "body"
        required: true
        schema:
          $ref: "#/definitions/Pet"
      responses:
        201:
          description: "Created"
        400:
          description: "Bad request"

definitions:
  Pet:
    type: "object"
    required:
    - "name"
    properties:
      id:
        type: "integer"
      name:
        type: "string"
        example: "doggie"

@gs11
Copy link

gs11 commented Mar 14, 2018

Issue remains with version 1.0.1, JSON converted swagger files work fine though.

@alext234
Copy link

alext234 commented Nov 5, 2019

I am having the same error when parsing a yaml file.

@couchotato
Copy link

I was able to track the problem down to python's re module and it is having problems with the yaml similar to the following

        201:
          description: "Created"
        400:
          description: "Bad request"

values 201 and 400 above are parsed as integers and therefore re complains about the type of the value being inserted.
Yaml below will work perfectly with the lib

        "201":
          description: "Created"
        "400":
          description: "Bad request"

I can make a pr

@flavianh
Copy link

flavianh commented May 24, 2020 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants