Skip to content
This repository has been archived by the owner on Dec 5, 2019. It is now read-only.

does not work with json-schema draft4 #10

Open
maxlinc opened this issue Aug 14, 2013 · 5 comments
Open

does not work with json-schema draft4 #10

maxlinc opened this issue Aug 14, 2013 · 5 comments

Comments

@maxlinc
Copy link
Collaborator

maxlinc commented Aug 14, 2013

see json-schema draft 4 changelog:
http://tools.ietf.org/html/draft-fge-json-schema-validation-00#appendix-A

This is problematic:

Redefine the "required" keyword.

@maxlinc
Copy link
Collaborator Author

maxlinc commented Sep 24, 2013

I haven't confirmed, but I think this may be an issue with the https://github.com/tmattia/json-generator project, not Pacto itself. I know json-schema supports json-4.

So you can't currently use Pacto's default mechanism for generating stubs using a contract with draft4, but you could use Pacto to validate responses (from live services or alternate stubbing systems).

@maxlinc
Copy link
Collaborator Author

maxlinc commented Dec 27, 2013

Current status:

  • json-schema and json-schema-generator both support draft3 or draft4.
  • json-generator does not support draft4.
  • meta-validation and validation support draft3 or draft4
  • Code that directly parses the json-schema has been removed.

@fishermand46
Copy link
Contributor

I'm having an issue which might be related to this. I have a swagger 2.0 contract which specifies two required int params, however, when I run the validations (contracts.simulate_consumers), Pacto makes an http call to the api endpoint with no params.

Applicable contract snippit:

paths:
  /add:
    get:
      summary: Adds two numbers
      parameters:
        - name: num1
          in: query
          required: true
          type: integer
          format: int32
        - name: num2
          in: query
          required: true
          type: integer
          format: int32
      responses:
        200:
          description: The result
          schema:
            type: integer
            format: int32

Generated Pacto::Swagger Request clause:

#<Pacto::Swagger::RequestClause host="http://localhost:3000" http_method=:get params={} path="/add" request_pattern_provider=#<Class:0x000001031aa0c8> schema={}>

Notice params is empty. Any ideas? I just started using Pacto, so I may just be missing something. Thanks.

@maxlinc
Copy link
Collaborator Author

maxlinc commented Jan 13, 2015

You probably found a bug... or a missing feature.

I think it's a different bug but the solution to both may involve moving the json-generator project back into Pacto (it was originally part of this project) or implementing/using some other system to generate test values.

I think it's a different issue because Swagger parameters are similar to json-schema but don't actually use json-schema. The "required" keyword, for example, acts different. It's actually similar to json-schema draft 3 (it's a boolean), but doesn't match json-schema draft 4 (where it's a list of key names of required properties).

@fishermand46
Copy link
Contributor

I made a comment on a commit. It looks like we're not pulling in the params from the swagger operation object.
I made a quick-and-dirty commit here which demonstrates pulling the params into the RequestClause constructor.
Lemme know if this makes any sense.

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

2 participants