Code Monkey home page Code Monkey logo

flex's Introduction

FLEX

Build Status Documentation Status PyPi version PyPi downloads

Validation tooling for Swagger 2.0 specifications.

Documentation on ReadTheDocs

Features

  • Validate swagger schemas.
  • JSON Schema Validation
  • Validation of request/response objects against schema.
  • Command Line interface.

CLI Name Change

Starting in version 5.0.0 the CLI interface has been changed to swagger-flex due to a collision with the Apache Flex project.

flex's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flex's Issues

Flex doesn't find referenced definitions

I am encountering a reference bug with flex (3.5.0).. It doesn't find referenced types in "#/definitions".. A sample:

 {
  "swagger" : "2.0",
  "info" : {
    "version" : "1.0",
    "title" : "Sample Rest API"
  },
  "basePath" : "/",
  "schemes" : [ "http" ],
  "consumes" : [ "application/json" ],
  "produces" : [ "application/json" ],
  "paths" : {
    "/status" : {
      "post" : {
        "parameters" : [ {
                        "in":"body",
                        "name": "token",
                        "schema" : {"$ref" : "#/definitions/TokenObj"}
          }
         ],
        "responses" : {
          "200" : {
            "description" : "retrieves the status"
          }
        }
      }
    }
  },
  "definitions" : {
    "TokenObj" : {
      "required" : [ "magic", "timestamp" ],
      "properties" : {
        "magic" : {
          "type" : "string"
        },
        "timestamp" : {
          "type" : "string"
        }
      },
      "type" : "object"
    }
  }
}

I receive the following output:

ValidationError: 'paths':
    - u'/status':
        - 'post':
            - 'parameters':
                - 'schema':
                    - '$ref':
                        - u'Unknown definition reference `#/definitions/TokenObj`'

This is only the simplest sample I could produce. References to #/parameters are working, but anything referencing items in #/definitions seems to be failing.

No paths found for /pets/dog.us

Hello, I am facing a new issue with the url validation.
My url is something like this: http://localhost/pets/dog.us?type=2&age=1
My swagger is something like this:

basePath: /localhost
paths:
  /pets/dog.us?type=2&age=1
    get:
      summary: Get dogs of type 2 and age 1
      responses:
        200:
          schema:
            $ref: Type2Age1

I am getting this error:

libs.flex.exceptions.ValidationError: 'request':
    - 'path':
        - 'No paths found for /pets/dog.us'

I took a look to paths :

{'/pets/dog.us?type=2&age=1': re.compile('^/pets/dog\\.us?type=2&age=1$')}

And the matching_api_paths:

[]

What do you think about the problem? Am I defining the path in 'swagger' wrongly? or do you think that is a flex issue?

Assert intersection error

I think we should change the way we validate the types, because this is a valid scenario:

properties:
type:
       type: string
       required: True

and because of this:

# I don't know why this set intersection is enforced...?  Why did I do this.
        intersection = set(schema['properties'].keys()).intersection(schema.keys())
        assert not intersection

I am getting the error: assert Intersection.

Unique constraint on arrays containing objects raises exception

We have a response for an endpoint defined as follows in our spec:

        responses:
          200:
            description: list of payment methods
            schema:
              type: object
              required:
                - data
              properties:
                data:
                  type: array
                  uniqueItems: true
                  items:
                    $ref: '#/definitions/PaymentMethod'

The important thing to note is that data here is an array containing objects. When validating a response from this endpoint, we get this exception raised:

 TypeError: unhashable type: 'dict'

I'm thinking that this is because when validating uniqueness, flex uses a counter here, which requires hashable types.

Here's the full stacktrace:

 /app/shared/virtualenvs/venmo_platform27/local/lib/python2.7/site-packages/flex/validation/response.py line 241 in validate_response
      response_validator(response, context=schema)
    /app/shared/virtualenvs/venmo_platform27/local/lib/python2.7/site-packages/flex/validation/common.py line 322 in validate_object
      schema_validators.validate_object(obj, context=context)
    /app/shared/virtualenvs/venmo_platform27/local/lib/python2.7/site-packages/flex/datastructures.py line 75 in validate_object
      validator(obj, **kwargs)
    /app/shared/virtualenvs/venmo_platform27/local/lib/python2.7/site-packages/flex/datastructures.py line 46 in __call__
      return self.validate_object(*args, **kwargs)
    /app/shared/virtualenvs/venmo_platform27/local/lib/python2.7/site-packages/flex/datastructures.py line 41 in validate_object
      validator(obj, **kwargs)
    /app/shared/virtualenvs/venmo_platform27/local/lib/python2.7/site-packages/flex/functional.py line 9 in chain_reduce
      value = function(value, **kwargs)
    /app/shared/virtualenvs/venmo_platform27/local/lib/python2.7/site-packages/flex/validation/common.py line 322 in validate_object
      schema_validators.validate_object(obj, context=context)
    /app/shared/virtualenvs/venmo_platform27/local/lib/python2.7/site-packages/flex/datastructures.py line 75 in validate_object
      validator(obj, **kwargs)
    /app/shared/virtualenvs/venmo_platform27/local/lib/python2.7/site-packages/flex/datastructures.py line 46 in __call__
      return self.validate_object(*args, **kwargs)
    /app/shared/virtualenvs/venmo_platform27/local/lib/python2.7/site-packages/flex/datastructures.py line 41 in validate_object
      validator(obj, **kwargs)
    /app/shared/virtualenvs/venmo_platform27/local/lib/python2.7/site-packages/flex/decorators.py line 52 in inner
      return func(value, *args, **kwargs)
    /app/shared/virtualenvs/venmo_platform27/local/lib/python2.7/site-packages/flex/decorators.py line 37 in inner
      return func(value, *args, **kwargs)
    /app/shared/virtualenvs/venmo_platform27/local/lib/python2.7/site-packages/flex/functional.py line 9 in chain_reduce
      value = function(value, **kwargs)
    /app/shared/virtualenvs/venmo_platform27/local/lib/python2.7/site-packages/flex/validation/common.py line 322 in validate_object
      schema_validators.validate_object(obj, context=context)
    /app/shared/virtualenvs/venmo_platform27/local/lib/python2.7/site-packages/flex/datastructures.py line 75 in validate_object
      validator(obj, **kwargs)
    /app/shared/virtualenvs/venmo_platform27/local/lib/python2.7/site-packages/flex/datastructures.py line 46 in __call__
      return self.validate_object(*args, **kwargs)
    /app/shared/virtualenvs/venmo_platform27/local/lib/python2.7/site-packages/flex/datastructures.py line 41 in validate_object
      validator(obj, **kwargs)
    /app/shared/virtualenvs/venmo_platform27/local/lib/python2.7/site-packages/flex/decorators.py line 52 in inner
      return func(value, *args, **kwargs)
    /app/shared/virtualenvs/venmo_platform27/local/lib/python2.7/site-packages/flex/decorators.py line 37 in inner
      return func(value, *args, **kwargs)
    /app/shared/virtualenvs/venmo_platform27/local/lib/python2.7/site-packages/flex/validation/common.py line 245 in validate_unique_items
      (v, type(v)) for v in value
    /usr/lib/python2.7/collections.py line 419 in __init__
      self.update(iterable, **kwds)
    /usr/lib/python2.7/collections.py line 501 in update
      self[elem] = self_get(elem, 0) + 1
   TypeError: unhashable type: 'dict'

Improve stacktraces

Currently, when something goes wrong inside of one of the custom validators, it can be really nasty to trace down exactly what is happening. This is largely due to most validation occuring in curried (functools.partial(...)) calls to validation functions which makes tracing down exactly who is passing the wrong type into something frustrating.

Some ideas to fix this are...

  • modify the return value of flex.validation.common.generate_object_validator to have a more descriptive name.
  • modify flex.functional.chain_reduce and flex.functional.apply_functions_to_key to have more descriptive names.

Flex doesn't correctly parse Reference Object in Parameters section. It's not parsing the referenced Parameter object?

Hi,
I've found that flex doesn't correctly validate a referenced parameter object.
An example to reproduce the error:

{
  "swagger" : "2.0",
  "info" : {
    "version" : "0.1",
    "title" : "SampleAPI"
  },
  "basePath" : "/rest",
  "schemes" : [ "http" ],
  "consumes" : [ "application/json" ],
  "produces" : [ "application/json" ],
  "paths" : {
    "/resource": {
      "post" : {
        "parameters" : [
            {"$ref" : "#/parameters/ParameterObject"}
        ],
        "responses" : {
          "200" : {
            "description" : "ok"
          }
        }
      }
    }

  },
  "parameters" : {
    "ParameterObject" : {
      "name" : "Parameter Object",
      "description" : "Fancy description",
      "in" : "body",
      "required" : true,
      "schema" : {
        "type" : "object",
        "properties" : {
          "ArrayOfItems" : {
            "type" : "array",
            "items" : {
              "$ref" : "#/definitions/RandomObject"
            }
          }
        }
      }
    }

  },
  "definitions" : {

    "RandomObject" : {
      "type" : "object",
      "properties" : {
        "id" : {
          "type" : "string"
        },
        "name" : {
          "type" : "string"
        },
        "version" : {
          "type" : "string"
        }
      }
    }
  }
}

I get the following output from flex:

Error: 'paths':
    - u'/resource':
        - 'post':
            - 'parameters':
                - 'required':
                    - 'name':
                        - u'This value is required'
                    - 'in':
                        - u'This value is required'

Obviously name and in are existing. I think this is easy to fix, since it seems to me that the reference object is validated instead of the parameter object that is referenced.
Thanks a lot for the good work and fast feedback!

Multiple paths found - Request path did not match any of the known api paths

Hi, I am facing new issues. Take a look at this:

/v1/pets/{petId}:
    get:
      summary: Info for a specific pet
      operationId: showPetById
      tags:
        - pets
      parameters:
        - name: petId
          in: path
          description: The id of the pet to retrieve
          type: string
      responses:
        200:
          description: Expected response to a valid request
          schema:
            $ref: Pets
/v1/pets/{petId}/name/{namePet}:
    get:
      description: get an pet with name
      tags:
        - pets
      parameters:
        - name: petId
          in: path
          description: ID of the pet
          required: true
          type: string
        - name: namePet
          in: path
          description: name of the pet
          required: true
          type: string
      responses:
        200:
          description: response of the pet
          schema:
              $ref: Pets

The problem is that this line:

 matches = [p for p, r in paths.items() if r.match(target_path)]

Returns more than one match:

['/v1/pets/{petId}', '/v1/pets/{petId}/name/{namePet}']

And I am getting the error: Request path did not match any of the known api paths.
I think that is not the expected behaviour, right?

required fields

Hi @pipermerriam, I found something that maybe we can improve.
At this moment the required fields should be set like this:

Pet:
    properties:
      id:
        type: integer
        required: true
        format: int64
      name:
        type: string
        required: true

But I saw the swagger specification and some examples and they do something like this:

Pet:
    required:
      - id
      - name
    properties:
      id:
        type: integer
        format: int64
      name:
        type: string

My problem with the actual solution, it's that when we use our swagger files with other tools for example swagger editor, it doesn't work.

What do you think about this @pipermerriam ?

Get rid of DRF dependency

No longer really needed and a pain to maintain. Replace the DRF stuff with a custom rolled validation system using the tools used to validate json schemas.

Add a command line interface.

Interesting tool - wondered if you'd accept a pul request to implement a commandline interface to flex - my use case is a community driven set of API specs that I want to keep validated to Swagger 2.0 and thus would like to have some sort of pre-commit / pre-merge continuous integration using a commandline validator.

Feature request/query

Hi!

Would it be possible to maintain the ordering of the entries: we have quite large schema in use, and we use this library to read the .yaml and then generate documentation out of it.

The .yaml file is ordered in some logical sense, and it would be great to maintain the same order. And the other side; who would not be happy if the ordering would be maintained with say OrderedDict like resolution?

Or is there even already option for this?

Cheers!
Pauli

support `responses.default`

According to the responses spec, a default key should be used to validate any response codes not explicitly declared. Right now, though, flex will raise invalid_status_code without checking for the presence of default.

This should be an easy fix: the check for default can be done here.

Flex is not validating correctly an url with query parameter

We added a new url with query parameter on our project, and we would like check this using Flex.
But we noticed when url with query parameter is not specified into swagger file, Flex doesn't validate correctly.
We have created a test to that before make any adding to swagger file, and Flex act as test is fine.
We assumed hope that Flex would show a error if this is trying call a url with query parameter, if this one is not specified in the swagger file.

$ref pointing to a external file

I am wondering if flex accept to use $ref pointing to an external file.

In the Swagger documentation say:

parts of the definitions can be split into separate files, at the discretion of the user. This is applicable for $ref fields in the specification as follows from the JSON Schema definitions.

Calling Flex, I tried to use json specifications, like:

      schema:
        $ref: 'modelswagger.yaml#/definitions/Model'

or following the Flex specifications to reference definitions. Without "definitions" word.

      schema:
        $ref: 'modelswagger.yaml#Model'

I get this:

  • '$ref':
    • 'Unknown definition reference account_swagger.yaml#/Account'

Is this possible implement on the Flex?
Does it worth do this?

Thanks.

Allow/disallow additional properties option

With JSON Schema's additionalProperties, by default any additional properties are allowed. However, I'd like to enforce the opposite -- additional properties are disallowed unless additionalProperties is specified.

For implementation, I was thinking I could add an argument allow_additional_properties to validate. allow_additional_properties would default to True, preserving the current default behavior. Then I'd pass that option through to construct_schema_validators to where we check if additionalProperties is False, and modify that conditional to also disallow additionalProperties if allow_additional_properties is False. Seems like this would work for validate, but I'd also want to add the option to validate_response. I'll need to do some more digging to see how to do that, since it looks like it doesn't call construct_schema_validators, but maybe I'm wrong about that.

Does this feature interest you? What do you think about the suggested implementation? I'd be happy to take a stab at it.

Request path did not match any of the known api paths

Hi, I am struggling with this new problem, I am using this example:

/v1/pets/{petId}:
    get:
      summary: Info for a specific pet
      operationId: showPetById
      tags:
        - pets
      parameters:
        - name: petId
          in: path
          description: The id of the pet to retrieve
          type: string
      responses:
        200:
          description: Expected response to a valid request
          schema:
            $ref: Pets
        default:
          description: unexpected error
          schema:
            $ref: Error

And when I do this:

import requests
from flex.core import load, validate_api_call
schema = load("schema.yaml")
response = requests.get('/v1/pets/dog')
validate_api_call(schema, raw_request=response.request, raw_response=response)

For some reason I am getting this error:

flex.exceptions.ValidationError: 'request':
    - 'path':
        - 'Request path did not match any of the known api paths.'

Is there something specific I should do in the schema to solve this?

Update documentation for validate_api_call

The validate_api_call method was updated but the documentation was not updated.

In this commit the validate_api_call was changed:

-def validate_api_call(schema, request, response):
+def validate_api_call(schema, raw_request, raw_response):

So the documentation should be updated

Validate parameters in body

Is there a way to validate parameters in the body?, if I have for example the following schema:

post:
      description: Creates a new pet in the store.  Duplicates are allowed
      operationId: addPet
      parameters:
        - name: pet
          in: body
          description: Pet to add to the store
          required: true
          schema:
            $ref: '#/definitions/NewPet'

Here is the link of the example I am using: https://github.com/swagger-api/swagger-spec/blob/master/examples/v2.0/yaml/petstore-expanded.yaml
There is a way to validate that the parameters received in the body of the post are right?
I saw in the documentation that this is not explicit so I think that maybe this feature don't exist.

Improve api path matching

The current api path matching leaves room for improvement in the case where multiple matches are found for a target path. This happens in pretty simple situations like nested resources.

  • /get/{id} => /get/(?P<id>.+)
  • /get/{id}/nested/{other_id} => /get/(?P<id>.+)/nested/(?P<other_id>.+)

Both of these path regexes will match /get/1234/nested/5678.

The current logic looks at the match with the most matched groups and assumes it is the correct path. I think this is a bit naive and may have false positives, or potentially pick the wrong path in specialized use cases.

I don't know that the correct approach is, but I think a start would be to use other factors in the definition of the parameter to generate stricter regexes. Fox example, path parameters that are of integer type could generate /get/(?P<id>\d+) so that it will only match paths that have numeric values in the location of id.

Another thing to take into account, is that adding this kind matching based on type will turn what should be a type error in the actual extracted parameter value into an error matching the path. I don't know which is the correct error to raise. Maybe there is a way to do both?

Match path to basePath

The OAS specification says that "The path is appended to the basePath in order to construct the full URL."

This (to me) implies that, to match a path defined in an OAS schema, a path would need to include the basePath. But in flex, if a path doesn't include the basePath, it's matched to the schema paths anyway.

The impact of this is, if an app has two endpoints: /cat and /v1/cat, and an OAS schema with a basePath of 'v1', responses from /cat could be validated against the schema for /v1/cat. Instead, I'd expect attempting to validate a response from /cat to raise a LookUpError with no matching paths found.

I'd be happy to fix this if you agree that it's a bug.

Here's my kitten:
https://dl.dropboxusercontent.com/content_link/7W3bWo0D1uOYXG5MlUtSOKBIIKsPoPZgBjiTZtZla3UxkDY8hqALMqNRqMsFDPqK/file

Allow nullable values

I would like to add a way to validate nullable values. I thought that the format validation might allow me to do this, but it is separate from the type validation. I don't mind submitting the code, but I would love a pointer on where to start.

The biggest potential issue is that swagger does not officially define nullable fields. In fact, null isn't allowed in the spec. So either a spec would need to be picked or it would need to be configurable. We have been using x-nullable: true in our specs. For example,

properties:
  id:
    type: integer
    format: int32
  organization_id:
    type: integer
    format: int32
  email:
    type: string
  first_name:
    type: string
    x-nullable: true

As per OAI/OpenAPI-Specification#229, x-nullable and x-isnullable seem to be popular choices for people with nullable fields.

query param in enum wrongly converted to boolean

Given the following swagger spec of a parameter:
name: whatever
in: query
type: string
enum

  • true

and the request contains a p=true in the query, the validation fails saying that true is not available as an option in the enum. this is because the true in the enum is converted to boolean at some point of the execution in the library. This happens if i put True capitalized in the enum options. If I put type: boolean in the spec, then still the library says that p is not valid, because is of type stsring and should be boolean.

Validate maxLenght of an string

It would be nice if flex validate the maxLenght of a string. For example:

properties:
   mystring:
        type: string
        maxLenght: 10

If mystring has more than 10 characters, flex raise an Error

Improve the maxLength validation message

Hi @pipermerriam I found something that seems an error

amount:
    type: string
    maxLength: 2

But when I send an amount of 5 characters, I got the validation message:

flex.exceptions.ValidationError: 'response':
    - 'body':
        - 'schema':
            - '$ref':
                - 'amount':
                    - 'maxLength':
                        - 'value must be no greater than 5 characters in length.'

The message should be something like value must be no greater than 2 characters in length
I am using the last version of flex.

AttributeError: 'int' object has no attribute 'get'

$ flex --source http://openfisca.sgmap.fr/api/1/swagger
Traceback (most recent call last):
โ€ฆ
  File "/usr/local/lib/python2.7/site-packages/flex/decorators.py", line 112, in inner
    kwargs[key] = obj.get(key, EMPTY)
AttributeError: 'int' object has no attribute 'get'

Ability to validate nested $ref objects

When using from flex.core import validate and calling validate(schema, data) to validate data against a schema, it doesn't use the nested $ref elements to validate the input data. Instead, the behavior I'm seeing is that it validates properties for schema, but does not validate the properties of any $ref found in the schema that is passed in.

ImportError: cannot import name PipSession

Excited to try out flex but it's failing on the pip install flex with ImportError: cannot import name PipSession

I attempted to install while in an active virtualenvs. When I deactivated, it worked.

full pip.log:

-----------------------------------------------------------
/Users/jmac/.virtualenvs/test/bin/pip run on Fri Apr 17 18:26:11 2015
Downloading/unpacking flex

  Getting page https://pypi.python.org/simple/flex/
  URLs to search for versions for flex:
  * https://pypi.python.org/simple/flex/
  Analyzing links from page https://pypi.python.org/simple/flex/
    Skipping link https://pypi.python.org/packages/2.7/f/flex/flex-2.1.0-py2-none-any.whl#md5=96236f480e1275a49ba9c5722436eaf1 (from https://pypi.python.org/simple/flex/); unknown archive format: .whl
    Skipping link https://pypi.python.org/packages/2.7/f/flex/flex-2.2.0-py2-none-any.whl#md5=06e87bb689e08d0ca05a3a65fc6dfd92 (from https://pypi.python.org/simple/flex/); unknown archive format: .whl
    Skipping link https://pypi.python.org/packages/2.7/f/flex/flex-2.3.0-py2-none-any.whl#md5=0cacdc8e292edce2b88848a3f8ac20d1 (from https://pypi.python.org/simple/flex/); unknown archive format: .whl
    Skipping link https://pypi.python.org/packages/2.7/f/flex/flex-2.4.0-py2-none-any.whl#md5=9e1bfc45eef93e5709cce185ae7fcdb7 (from https://pypi.python.org/simple/flex/); unknown archive format: .whl
    Skipping link https://pypi.python.org/packages/2.7/f/flex/flex-2.5.0-py2-none-any.whl#md5=6f5ad0400661857795fe3b346c8cc330 (from https://pypi.python.org/simple/flex/); unknown archive format: .whl
    Skipping link https://pypi.python.org/packages/2.7/f/flex/flex-2.6.0-py2-none-any.whl#md5=07a3ac34578d68d6dbfd427fe0a8a2fe (from https://pypi.python.org/simple/flex/); unknown archive format: .whl
    Skipping link https://pypi.python.org/packages/2.7/f/flex/flex-2.7.0-py2-none-any.whl#md5=91d8817890ed6f3a99f47b28573eaef1 (from https://pypi.python.org/simple/flex/); unknown archive format: .whl
    Skipping link https://pypi.python.org/packages/2.7/f/flex/flex-2.8.0-py2-none-any.whl#md5=20d4f475b3acce2e7275f60a82d116fe (from https://pypi.python.org/simple/flex/); unknown archive format: .whl
    Skipping link https://pypi.python.org/packages/2.7/f/flex/flex-3.0.0-py2-none-any.whl#md5=b5c2edbd7be990094dae4cc1484f2929 (from https://pypi.python.org/simple/flex/); unknown archive format: .whl
    Skipping link https://pypi.python.org/packages/2.7/f/flex/flex-3.1.0-py2-none-any.whl#md5=e2ddbdeea959a0749a6c7ac90b3ea35f (from https://pypi.python.org/simple/flex/); unknown archive format: .whl
    Skipping link https://pypi.python.org/packages/2.7/f/flex/flex-3.2.0-py2-none-any.whl#md5=3d31251d2afdfae4f966d779dcf4b4c7 (from https://pypi.python.org/simple/flex/); unknown archive format: .whl
    Skipping link https://pypi.python.org/packages/2.7/f/flex/flex-3.3.0-py2-none-any.whl#md5=b3f2c604a7b4f4589a36d48bb2d63e6d (from https://pypi.python.org/simple/flex/); unknown archive format: .whl
    Skipping link https://pypi.python.org/packages/2.7/f/flex/flex-3.4.0-py2-none-any.whl#md5=cc79fec9685c985af5218fb64ed7052d (from https://pypi.python.org/simple/flex/); unknown archive format: .whl
    Skipping link https://pypi.python.org/packages/2.7/f/flex/flex-3.4.1-py2-none-any.whl#md5=ab53845d2ac011598b8b7dcba429cf45 (from https://pypi.python.org/simple/flex/); unknown archive format: .whl
    Skipping link https://pypi.python.org/packages/2.7/f/flex/flex-3.5.0-py2-none-any.whl#md5=5c7ca5489714e68a071afe2a2ca6caf5 (from https://pypi.python.org/simple/flex/); unknown archive format: .whl
    Skipping link https://pypi.python.org/packages/2.7/f/flex/flex-3.5.1-py2-none-any.whl#md5=ceba56bd41f8dc152cb89b1197957d93 (from https://pypi.python.org/simple/flex/); unknown archive format: .whl
    Skipping link https://pypi.python.org/packages/2.7/f/flex/flex-4.0.0-py2-none-any.whl#md5=2053d494350eff51530c11dade68b4b3 (from https://pypi.python.org/simple/flex/); unknown archive format: .whl
    Found link https://pypi.python.org/packages/any/f/flex/flex-2.1.0.macosx-10.10-x86_64.tar.gz#md5=acf62f066411583b0e1df4ab7e98e692 (from https://pypi.python.org/simple/flex/), version: 2.1.0.macosx-10.10-x86_64
    Found link https://pypi.python.org/packages/any/f/flex/flex-2.2.0.macosx-10.10-x86_64.tar.gz#md5=6e28c39eb689fbed209cd6ff0161466a (from https://pypi.python.org/simple/flex/), version: 2.2.0.macosx-10.10-x86_64
    Found link https://pypi.python.org/packages/any/f/flex/flex-2.3.0.macosx-10.10-x86_64.tar.gz#md5=2560721ec8a7101206bec2a02e8c1328 (from https://pypi.python.org/simple/flex/), version: 2.3.0.macosx-10.10-x86_64
    Found link https://pypi.python.org/packages/any/f/flex/flex-2.4.0.macosx-10.10-x86_64.tar.gz#md5=a2b14268022ba352c46cb0fc3f6ce609 (from https://pypi.python.org/simple/flex/), version: 2.4.0.macosx-10.10-x86_64
    Found link https://pypi.python.org/packages/any/f/flex/flex-2.5.0.macosx-10.10-x86_64.tar.gz#md5=49e95273d23a8c83bf2b6060a11bfe0d (from https://pypi.python.org/simple/flex/), version: 2.5.0.macosx-10.10-x86_64
    Found link https://pypi.python.org/packages/any/f/flex/flex-2.6.0.macosx-10.10-x86_64.tar.gz#md5=cbd8a7b5a71d6274ff70d5e1683c382f (from https://pypi.python.org/simple/flex/), version: 2.6.0.macosx-10.10-x86_64
    Found link https://pypi.python.org/packages/any/f/flex/flex-2.7.0.macosx-10.10-x86_64.tar.gz#md5=13cb539d02c1043453ac9fbea606ccbe (from https://pypi.python.org/simple/flex/), version: 2.7.0.macosx-10.10-x86_64
    Found link https://pypi.python.org/packages/any/f/flex/flex-2.8.0.macosx-10.10-x86_64.tar.gz#md5=d8d3f2ef2c71a8de8347f96e37fdce9d (from https://pypi.python.org/simple/flex/), version: 2.8.0.macosx-10.10-x86_64
    Found link https://pypi.python.org/packages/any/f/flex/flex-3.0.0.macosx-10.10-x86_64.tar.gz#md5=6631a3f76049a0b22992f1b11dc99f59 (from https://pypi.python.org/simple/flex/), version: 3.0.0.macosx-10.10-x86_64
    Found link https://pypi.python.org/packages/any/f/flex/flex-3.1.0.macosx-10.10-x86_64.tar.gz#md5=7539da3bccd62093be1b096094f7fc44 (from https://pypi.python.org/simple/flex/), version: 3.1.0.macosx-10.10-x86_64
    Found link https://pypi.python.org/packages/any/f/flex/flex-3.2.0.macosx-10.10-x86_64.tar.gz#md5=9e59c628faaecbbf93f62cb3d85dd46b (from https://pypi.python.org/simple/flex/), version: 3.2.0.macosx-10.10-x86_64
    Found link https://pypi.python.org/packages/any/f/flex/flex-3.3.0.macosx-10.10-x86_64.tar.gz#md5=52fe0f56aa3b3a13fe83f687474d4a99 (from https://pypi.python.org/simple/flex/), version: 3.3.0.macosx-10.10-x86_64
    Found link https://pypi.python.org/packages/any/f/flex/flex-3.4.0.macosx-10.10-x86_64.tar.gz#md5=9a91c29cfd6999f35af588b6714c6bdd (from https://pypi.python.org/simple/flex/), version: 3.4.0.macosx-10.10-x86_64
    Found link https://pypi.python.org/packages/any/f/flex/flex-3.4.1.macosx-10.10-x86_64.tar.gz#md5=9a0ae5b77f7fece64a3a6635872a5bd0 (from https://pypi.python.org/simple/flex/), version: 3.4.1.macosx-10.10-x86_64
    Found link https://pypi.python.org/packages/any/f/flex/flex-3.5.0.macosx-10.10-x86_64.tar.gz#md5=a1156524b44be68627d0e0e8cdd4efee (from https://pypi.python.org/simple/flex/), version: 3.5.0.macosx-10.10-x86_64
    Found link https://pypi.python.org/packages/any/f/flex/flex-3.5.1.macosx-10.10-x86_64.tar.gz#md5=cb4bad77109acd19bd4649289f99d697 (from https://pypi.python.org/simple/flex/), version: 3.5.1.macosx-10.10-x86_64
    Found link https://pypi.python.org/packages/any/f/flex/flex-4.0.0.macosx-10.10-x86_64.tar.gz#md5=e9a8f78e5011594f574affd2cf285c18 (from https://pypi.python.org/simple/flex/), version: 4.0.0.macosx-10.10-x86_64
    Found link https://pypi.python.org/packages/source/f/flex/flex-1.0.0.tar.gz#md5=1018702e4443d0a7a9d9bd2107310b94 (from https://pypi.python.org/simple/flex/), version: 1.0.0
    Found link https://pypi.python.org/packages/source/f/flex/flex-1.1.0.tar.gz#md5=30495feb0099a178dcdc5e49c51fa425 (from https://pypi.python.org/simple/flex/), version: 1.1.0
    Found link https://pypi.python.org/packages/source/f/flex/flex-1.2.0.tar.gz#md5=d736158d9df43474679114d43058097d (from https://pypi.python.org/simple/flex/), version: 1.2.0
    Found link https://pypi.python.org/packages/source/f/flex/flex-1.3.0.tar.gz#md5=249b7c00dc4245a712d1de580f29ea2c (from https://pypi.python.org/simple/flex/), version: 1.3.0
    Found link https://pypi.python.org/packages/source/f/flex/flex-1.4.0.tar.gz#md5=6b7987bb7099da118c374951a6d53ae7 (from https://pypi.python.org/simple/flex/), version: 1.4.0
    Found link https://pypi.python.org/packages/source/f/flex/flex-1.5.0.tar.gz#md5=9a295ffaf15875c8c132368cee45866f (from https://pypi.python.org/simple/flex/), version: 1.5.0
    Found link https://pypi.python.org/packages/source/f/flex/flex-1.6.0.tar.gz#md5=4526002b71e95a224d6190f38e16edc9 (from https://pypi.python.org/simple/flex/), version: 1.6.0
    Found link https://pypi.python.org/packages/source/f/flex/flex-1.7.0.tar.gz#md5=448391a732d90d2cee4e7c74e2b8fbd0 (from https://pypi.python.org/simple/flex/), version: 1.7.0
    Found link https://pypi.python.org/packages/source/f/flex/flex-1.8.0.tar.gz#md5=e3c3d4fb0a21e2bf64cd0795751bf6a8 (from https://pypi.python.org/simple/flex/), version: 1.8.0
    Found link https://pypi.python.org/packages/source/f/flex/flex-1.9.0.tar.gz#md5=4311508b8b5f08b6ce1e042ee864c44d (from https://pypi.python.org/simple/flex/), version: 1.9.0
    Found link https://pypi.python.org/packages/source/f/flex/flex-2.0.0.tar.gz#md5=f7c529d270cbb4304d6cc8cd04ea5214 (from https://pypi.python.org/simple/flex/), version: 2.0.0
    Found link https://pypi.python.org/packages/source/f/flex/flex-2.1.0.tar.gz#md5=8809a0bbe1627ad80212e0956c2825cc (from https://pypi.python.org/simple/flex/), version: 2.1.0
    Found link https://pypi.python.org/packages/source/f/flex/flex-2.2.0.tar.gz#md5=151661ef30d890445cc0159690fc9545 (from https://pypi.python.org/simple/flex/), version: 2.2.0
    Found link https://pypi.python.org/packages/source/f/flex/flex-2.3.0.tar.gz#md5=73e5614ec8b756a64d975cf565885df3 (from https://pypi.python.org/simple/flex/), version: 2.3.0
    Found link https://pypi.python.org/packages/source/f/flex/flex-2.4.0.tar.gz#md5=78119930f6f66b9c804c1dfe47827d71 (from https://pypi.python.org/simple/flex/), version: 2.4.0
    Found link https://pypi.python.org/packages/source/f/flex/flex-2.5.0.tar.gz#md5=f844ae18856c44eb73533ea2a127f7e6 (from https://pypi.python.org/simple/flex/), version: 2.5.0
    Found link https://pypi.python.org/packages/source/f/flex/flex-2.6.0.tar.gz#md5=79bb821c782226e81bd988bad2e40b15 (from https://pypi.python.org/simple/flex/), version: 2.6.0
    Found link https://pypi.python.org/packages/source/f/flex/flex-2.7.0.tar.gz#md5=c9f344f547974998885011478cbc892e (from https://pypi.python.org/simple/flex/), version: 2.7.0
    Found link https://pypi.python.org/packages/source/f/flex/flex-2.8.0.tar.gz#md5=be62c79489715f00f93686344b5a500e (from https://pypi.python.org/simple/flex/), version: 2.8.0
    Found link https://pypi.python.org/packages/source/f/flex/flex-3.0.0.tar.gz#md5=f6fd7589ad19e62cc5b3664cc2f54509 (from https://pypi.python.org/simple/flex/), version: 3.0.0
    Found link https://pypi.python.org/packages/source/f/flex/flex-3.1.0.tar.gz#md5=9031eefd1079733bb3bd8f7aa84cdaee (from https://pypi.python.org/simple/flex/), version: 3.1.0
    Found link https://pypi.python.org/packages/source/f/flex/flex-3.2.0.tar.gz#md5=169b6c22645f1b5c97cba503ef95cede (from https://pypi.python.org/simple/flex/), version: 3.2.0
    Found link https://pypi.python.org/packages/source/f/flex/flex-3.3.0.tar.gz#md5=ab8cdc7c543e500a7a4347e93ae90aa8 (from https://pypi.python.org/simple/flex/), version: 3.3.0
    Found link https://pypi.python.org/packages/source/f/flex/flex-3.4.0.tar.gz#md5=f568a75e5b92989353585a1a67ec9ac6 (from https://pypi.python.org/simple/flex/), version: 3.4.0
    Found link https://pypi.python.org/packages/source/f/flex/flex-3.4.1.tar.gz#md5=54f1a23de11974853a8166912ec48ceb (from https://pypi.python.org/simple/flex/), version: 3.4.1
    Found link https://pypi.python.org/packages/source/f/flex/flex-3.5.0.tar.gz#md5=b69478a737007bed231a05b249f5e5b1 (from https://pypi.python.org/simple/flex/), version: 3.5.0
    Found link https://pypi.python.org/packages/source/f/flex/flex-3.5.1.tar.gz#md5=dc495484eb7d54c51ab3fa12731583a7 (from https://pypi.python.org/simple/flex/), version: 3.5.1
    Found link https://pypi.python.org/packages/source/f/flex/flex-4.0.0.tar.gz#md5=73aefc1363cc545f61a01e69a8be9d29 (from https://pypi.python.org/simple/flex/), version: 4.0.0
  Ignoring link https://pypi.python.org/packages/any/f/flex/flex-2.1.0.macosx-10.10-x86_64.tar.gz#md5=acf62f066411583b0e1df4ab7e98e692 (from https://pypi.python.org/simple/flex/), version 2.1.0.macosx-10.10-x86_64 is a pre-release (use --pre to allow).
  Ignoring link https://pypi.python.org/packages/any/f/flex/flex-2.2.0.macosx-10.10-x86_64.tar.gz#md5=6e28c39eb689fbed209cd6ff0161466a (from https://pypi.python.org/simple/flex/), version 2.2.0.macosx-10.10-x86_64 is a pre-release (use --pre to allow).
  Ignoring link https://pypi.python.org/packages/any/f/flex/flex-2.3.0.macosx-10.10-x86_64.tar.gz#md5=2560721ec8a7101206bec2a02e8c1328 (from https://pypi.python.org/simple/flex/), version 2.3.0.macosx-10.10-x86_64 is a pre-release (use --pre to allow).
  Ignoring link https://pypi.python.org/packages/any/f/flex/flex-2.4.0.macosx-10.10-x86_64.tar.gz#md5=a2b14268022ba352c46cb0fc3f6ce609 (from https://pypi.python.org/simple/flex/), version 2.4.0.macosx-10.10-x86_64 is a pre-release (use --pre to allow).
  Ignoring link https://pypi.python.org/packages/any/f/flex/flex-2.5.0.macosx-10.10-x86_64.tar.gz#md5=49e95273d23a8c83bf2b6060a11bfe0d (from https://pypi.python.org/simple/flex/), version 2.5.0.macosx-10.10-x86_64 is a pre-release (use --pre to allow).
  Ignoring link https://pypi.python.org/packages/any/f/flex/flex-2.6.0.macosx-10.10-x86_64.tar.gz#md5=cbd8a7b5a71d6274ff70d5e1683c382f (from https://pypi.python.org/simple/flex/), version 2.6.0.macosx-10.10-x86_64 is a pre-release (use --pre to allow).
  Ignoring link https://pypi.python.org/packages/any/f/flex/flex-2.7.0.macosx-10.10-x86_64.tar.gz#md5=13cb539d02c1043453ac9fbea606ccbe (from https://pypi.python.org/simple/flex/), version 2.7.0.macosx-10.10-x86_64 is a pre-release (use --pre to allow).
  Ignoring link https://pypi.python.org/packages/any/f/flex/flex-2.8.0.macosx-10.10-x86_64.tar.gz#md5=d8d3f2ef2c71a8de8347f96e37fdce9d (from https://pypi.python.org/simple/flex/), version 2.8.0.macosx-10.10-x86_64 is a pre-release (use --pre to allow).
  Ignoring link https://pypi.python.org/packages/any/f/flex/flex-3.0.0.macosx-10.10-x86_64.tar.gz#md5=6631a3f76049a0b22992f1b11dc99f59 (from https://pypi.python.org/simple/flex/), version 3.0.0.macosx-10.10-x86_64 is a pre-release (use --pre to allow).
  Ignoring link https://pypi.python.org/packages/any/f/flex/flex-3.1.0.macosx-10.10-x86_64.tar.gz#md5=7539da3bccd62093be1b096094f7fc44 (from https://pypi.python.org/simple/flex/), version 3.1.0.macosx-10.10-x86_64 is a pre-release (use --pre to allow).
  Ignoring link https://pypi.python.org/packages/any/f/flex/flex-3.2.0.macosx-10.10-x86_64.tar.gz#md5=9e59c628faaecbbf93f62cb3d85dd46b (from https://pypi.python.org/simple/flex/), version 3.2.0.macosx-10.10-x86_64 is a pre-release (use --pre to allow).
  Ignoring link https://pypi.python.org/packages/any/f/flex/flex-3.3.0.macosx-10.10-x86_64.tar.gz#md5=52fe0f56aa3b3a13fe83f687474d4a99 (from https://pypi.python.org/simple/flex/), version 3.3.0.macosx-10.10-x86_64 is a pre-release (use --pre to allow).
  Ignoring link https://pypi.python.org/packages/any/f/flex/flex-3.4.0.macosx-10.10-x86_64.tar.gz#md5=9a91c29cfd6999f35af588b6714c6bdd (from https://pypi.python.org/simple/flex/), version 3.4.0.macosx-10.10-x86_64 is a pre-release (use --pre to allow).
  Ignoring link https://pypi.python.org/packages/any/f/flex/flex-3.4.1.macosx-10.10-x86_64.tar.gz#md5=9a0ae5b77f7fece64a3a6635872a5bd0 (from https://pypi.python.org/simple/flex/), version 3.4.1.macosx-10.10-x86_64 is a pre-release (use --pre to allow).
  Ignoring link https://pypi.python.org/packages/any/f/flex/flex-3.5.0.macosx-10.10-x86_64.tar.gz#md5=a1156524b44be68627d0e0e8cdd4efee (from https://pypi.python.org/simple/flex/), version 3.5.0.macosx-10.10-x86_64 is a pre-release (use --pre to allow).
  Ignoring link https://pypi.python.org/packages/any/f/flex/flex-3.5.1.macosx-10.10-x86_64.tar.gz#md5=cb4bad77109acd19bd4649289f99d697 (from https://pypi.python.org/simple/flex/), version 3.5.1.macosx-10.10-x86_64 is a pre-release (use --pre to allow).
  Ignoring link https://pypi.python.org/packages/any/f/flex/flex-4.0.0.macosx-10.10-x86_64.tar.gz#md5=e9a8f78e5011594f574affd2cf285c18 (from https://pypi.python.org/simple/flex/), version 4.0.0.macosx-10.10-x86_64 is a pre-release (use --pre to allow).
  Using version 4.0.0 (newest of versions: 4.0.0, 3.5.1, 3.5.0, 3.4.1, 3.4.0, 3.3.0, 3.2.0, 3.1.0, 3.0.0, 2.8.0, 2.7.0, 2.6.0, 2.5.0, 2.4.0, 2.3.0, 2.2.0, 2.1.0, 2.0.0, 1.9.0, 1.8.0, 1.7.0, 1.6.0, 1.5.0, 1.4.0, 1.3.0, 1.2.0, 1.1.0, 1.0.0)
  Downloading flex-4.0.0.tar.gz

  Downloading from URL https://pypi.python.org/packages/source/f/flex/flex-4.0.0.tar.gz#md5=73aefc1363cc545f61a01e69a8be9d29 (from https://pypi.python.org/simple/flex/)
  Running setup.py egg_info for package flex

    Traceback (most recent call last):

      File "<string>", line 16, in <module>

      File "/Users/jmac/.virtualenvs/test/build/flex/setup.py", line 4, in <module>

        from pip.download import PipSession

    ImportError: cannot import name PipSession

    Complete output from command python setup.py egg_info:

    Traceback (most recent call last):

  File "<string>", line 16, in <module>

  File "/Users/jmac/.virtualenvs/test/build/flex/setup.py", line 4, in <module>

    from pip.download import PipSession

ImportError: cannot import name PipSession

----------------------------------------

Cleaning up...

  Removing temporary dir /Users/jmac/.virtualenvs/test/build...
Command python setup.py egg_info failed with error code 1 in /Users/jmac/.virtualenvs/test/build/flex

Exception information:
Traceback (most recent call last):
  File "/Users/jmac/.virtualenvs/test/lib/python2.7/site-packages/pip/basecommand.py", line 134, in main
    status = self.run(options, args)
  File "/Users/jmac/.virtualenvs/test/lib/python2.7/site-packages/pip/commands/install.py", line 236, in run
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "/Users/jmac/.virtualenvs/test/lib/python2.7/site-packages/pip/req.py", line 1134, in prepare_files
    req_to_install.run_egg_info()
  File "/Users/jmac/.virtualenvs/test/lib/python2.7/site-packages/pip/req.py", line 259, in run_egg_info
    command_desc='python setup.py egg_info')
  File "/Users/jmac/.virtualenvs/test/lib/python2.7/site-packages/pip/util.py", line 670, in call_subprocess
    % (command_desc, proc.returncode, cwd))
InstallationError: Command python setup.py egg_info failed with error code 1 in /Users/jmac/.virtualenvs/test/build/flex

Petstore example broken

The petstore example is pretty popular for newbies at swagger.io because it's simple and often used. Unfortunatly flex 4.01 seems to have problems with the current specs. file:

ValidationError: 'info':
    - 'contact':
        - 'type':
            - u"Got value `{u'email': u'[email protected]'}` of type `object`.
  Value must be of type(s): `(u'string',)`"
    - 'license':
        - 'type':
            - u"Got value `{u'url': u'http://www.apache.org/licenses/LICENSE-2.0
.html', u'name': u'Apache 2.0'}` of type `object`.  Value must be of type(s): `(
u'string',)`"
'paths':
    - u'/pet/findByStatus':
        - 'get':
            - 'parameters':
                - 'default':
                    - u"The value of `default` must be of one of the declared ty
pes for the schema.  `available` is not one of `[u'array']`"
    - u'/pet/{petId}/uploadImage':
        - 'post':
            - 'parameters':
                - 'type':
                    - 'type':
                        - 'enum':
                            - u"Invalid value.  file is not one of the available
 options ([u'null', u'boolean', u'integer', u'number', u'string', u'array'])"

Can anybody please tell if this is already in focus (and maybe covered by other issues) ?

Validation incorrectly allows additional properties

Validation allows additional properties if "additionalProperties" is set to False in the schema. Instead, the validator should raise an exception. The JSON Schema validation specification, section 5.4.4.4 contains the rules on how to handle "additionalProperties".

from flex.core import validate
schema = {
  'type': 'object',
  'additionalProperties': False,
  'properties': {
    'name': {
      'type': 'string',
      'minLength': 3,
    },
  }
}
data = {
  'wrong': 10,
}
validate(schema, data)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.