When I run dredd, im not getting any kind of body on PUT/POST. Its just an empty string in the request
$ RAILS_ENV=test dredd http://localhost:3001/api_docs http://localhost:3001 --language ruby -f ./integration/hooks.rb --hooks-worker-connect-timeout 6000
dredd.yml?no dredd file
dredd --version output?dredd v2.2.1 (Darwin 16.1.0; x64)
{
"swagger": "2.0",
"host": "localhost:3001",
"consumes": [
"application/json"
],
"produces": [
"application/json; charset=utf-8"
],
"basePath": "/",
"info": {
"version": "0.1.0",
"title": "api documentation",
"description": "documentation",
"contact": {
"name": "author"
}
},
"securityDefinitions": {
"basic": {
"type": "basic",
"description": "HTTP Basic Authentication"
}
},
"parameters": {
"location": {
"name": "location",
"in": "query",
"description": "Location (latitude, longitude)",
"required": false,
"type": "string"
},
"range": {
"name": "range",
"in": "query",
"description": "Range (in miles)",
"required": false,
"type": "integer",
"format": "int32"
},
"search": {
"name": "search",
"in": "query",
"description": "Search",
"required": false,
"type": "string"
},
"order": {
"name": "order",
"in": "query",
"description": "Sort order. (ex 'name DESC')",
"required": false,
"type": "string"
},
"page": {
"name": "page",
"in": "query",
"description": "Page number (ex 2)",
"required": false,
"type": "integer",
"format": "int32"
},
"per_page": {
"name": "per_page",
"in": "query",
"description": "Items per page",
"required": false,
"type": "integer",
"format": "int32"
},
"id": {
"name": "id",
"x-example": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"in": "path",
"description": "Item Identifier",
"required": true,
"type": "string"
}
},
"paths": {
"/companies": {
"get": {
"description": "Get a list of companies",
"operationId": "findCompanies",
"tags": [
"Companies"
],
"parameters": [
{
"$ref": "#/parameters/location"
},
{
"$ref": "#/parameters/range"
},
{
"$ref": "#/parameters/search"
},
{
"$ref": "#/parameters/order"
},
{
"$ref": "#/parameters/page"
},
{
"$ref": "#/parameters/per_page"
}
],
"responses": {
"200": {
"description": "Company response",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Company"
}
}
}
}
},
"post": {
"description": "Create a company",
"operationId": "createCompanyById",
"tags": [
"Companies"
],
"security": [
{
"basic": []
}
],
"parameters": [
{
"name": "company",
"in": "body",
"description": "Company attributes to create company with",
"required": true,
"schema": {
"$ref": "#/definitions/Company"
}
}
],
"responses": {
"201": {
"description": "Company response",
"schema": {
"$ref": "#/definitions/Company"
}
}
}
}
},
"/companies/{id}": {
"parameters": [
{
"$ref": "#/parameters/id"
}
],
"get": {
"description": "Get a company",
"operationId": "findCompanybyId",
"tags": [
"Companies"
],
"responses": {
"200": {
"description": "Company response",
"schema": {
"$ref": "#/definitions/Company"
}
}
}
},
"put": {
"description": "Update a company",
"operationId": "updateCompanyById",
"tags": [
"Companies"
],
"security": [
{
"basic": []
}
],
"parameters": [
{
"name": "company",
"in": "body",
"description": "Company attributes to update company with",
"required": true,
"schema": {
"$ref": "#/definitions/CompanyInput"
}
}
],
"responses": {
"200": {
"description": "Company response",
"schema": {
"$ref": "#/definitions/Company"
}
}
}
},
"delete": {
"description": "Delete a company",
"operationId": "deleteCompanyById",
"tags": [
"Companies"
],
"security": [
{
"basic": []
}
],
"responses": {
"200": {
"description": "Company response",
"schema": {
"$ref": "#/definitions/Company"
}
}
}
}
}
},
"definitions": {
"Company": {
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string",
"pattern": "[a-zA-Z].*"
},
"description": {
"type": [
"string",
"null"
]
},
"phone": {
"type": "string"
},
"website": {
"type": "string",
"format": "url"
}
},
"required": [
"name",
"website",
"phone"
]
},
"CompanyInput": {
"allOf": [
{
"$ref": "#/definitions/Company"
}
]
}
}
}
$ RAILS_ENV=test dredd http://localhost:3001/api_docs http://localhost:3001 --language ruby -f ./integration/hooks.rb --hooks-worker-connect-timeout 6000 --level=debug
verbose: Loading configuration file: ./dredd.yml
debug: Dredd version: 2.2.1
debug: Node.js version: v5.6.0
debug: Node.js environment: http_parser=2.6.1, node=5.6.0, v8=4.6.85.31, uv=1.8.0, zlib=1.2.8, ares=1.10.1-DEV, icu=56.1, modules=47, openssl=1.0.2f
debug: System version: Darwin 16.1.0 x64
debug: npm version: 3.6.0
debug: Configuration: {"server":"http://localhost:3001","options":{"_":["http://localhost:3001/api_docs"],"language":"ruby","a":"ruby","f":"./integration/hooks.rb","hookfiles":"./integration/hooks.rb","hooks-worker-connect-timeout":6000,"level":"debug","l":"debug","dry-run":null,"y":null,"sandbox":false,"b":false,"server":null,"g":null,"server-wait":3,"init":false,"i":false,"custom":{},"j":[],"names":false,"n":false,"only":[],"x":[],"reporter":[],"r":[],"output":[],"o":[],"header":[],"h":[],"sorted":false,"s":false,"user":null,"u":null,"inline-errors":false,"e":false,"details":false,"d":false,"method":[],"m":[],"color":true,"c":true,"timestamp":false,"t":false,"silent":false,"q":false,"path":["http://localhost:3001/api_docs","http://localhost:3001/api_docs"],"p":["http://localhost:3001/api_docs","http://localhost:3001/api_docs"],"hooks-worker-timeout":5000,"hooks-worker-connect-retry":500,"hooks-worker-after-connect-wait":100,"hooks-worker-term-timeout":5000,"hooks-worker-term-retry":500,"hooks-worker-handler-host":"localhost","hooks-worker-handler-port":61321,"config":"./dredd.yml","$0":"dredd"},"custom":{"cwd":"/Users/<username>/workshop/<appname>/<appname>-rails","argv":["http://localhost:3001/api_docs","http://localhost:3001","--language","ruby","-f","./integration/hooks.rb","--hooks-worker-connect-timeout","6000","--level=debug"]}}
verbose: Using 'base' reporter.
verbose: Configuring reporters: []
verbose: Using 'cli' reporter.
verbose: No backend server process specified, starting testing at once.
verbose: Running Dredd instance.
verbose: Expanding glob patterns.
verbose: Reading API description files.
verbose: Downloading remote file: http://localhost:3001/api_docs
verbose: Parsing API description files and compiling a list of HTTP transactions to test.
verbose: Compiling HTTP transactions from API description file: http://localhost:3001/api_docs
warn: Parser warning in file 'http://localhost:3001/api_docs': (warning code 3) Unable to generate application/json; charset=utf-8 example message body out of JSON Schema on line 111
warn: Parser warning in file 'http://localhost:3001/api_docs': (warning code 3) Unable to generate application/json example message body out of JSON Schema on line 139
warn: Parser warning in file 'http://localhost:3001/api_docs': (warning code 3) Unable to generate application/json; charset=utf-8 example message body out of JSON Schema on line 147
warn: Parser warning in file 'http://localhost:3001/api_docs': (warning code 3) Unable to generate application/json; charset=utf-8 example message body out of JSON Schema on line 169
warn: Parser warning in file 'http://localhost:3001/api_docs': (warning code 3) Unable to generate application/json example message body out of JSON Schema on line 194
warn: Parser warning in file 'http://localhost:3001/api_docs': (warning code 3) Unable to generate application/json; charset=utf-8 example message body out of JSON Schema on line 202
warn: Parser warning in file 'http://localhost:3001/api_docs': (warning code 3) Unable to generate application/json; charset=utf-8 example message body out of JSON Schema on line 224
verbose: Starting reporters and waiting until all of them are ready.
info: Beginning Dredd testing...
verbose: Starting transaction runner.
verbose: Sorting HTTP transactions.
verbose: Configuring HTTP transactions.
verbose: Reading hook files and registering hooks.
info: Found Hookfiles: 0=./integration/hooks.rb
verbose: Looking up hooks handler implementation: ruby
verbose: Starting hooks handler.
info: Spawning `ruby` hooks handler process.
verbose: Connecting to hooks handler.
verbose: Starting TCP connection with hooks handler process.
debug: TCP communication with hooks handler errored. Error: connect ECONNREFUSED 127.0.0.1:61321
at Object.exports._errnoException (util.js:856:11)
at exports._exceptionWithHostPort (util.js:879:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1053:14)
debug: TCP communication with hooks handler closed.
warn: Error connecting to the hooks handler process. Is the handler running? Retrying.
verbose: Starting TCP connection with hooks handler process.
debug: TCP communication with hooks handler errored. Error: connect ECONNREFUSED 127.0.0.1:61321
at Object.exports._errnoException (util.js:856:11)
at exports._exceptionWithHostPort (util.js:879:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1053:14)
debug: TCP communication with hooks handler closed.
warn: Error connecting to the hooks handler process. Is the handler running? Retrying.
verbose: Starting TCP connection with hooks handler process.
debug: TCP communication with hooks handler errored. Error: connect ECONNREFUSED 127.0.0.1:61321
at Object.exports._errnoException (util.js:856:11)
at exports._exceptionWithHostPort (util.js:879:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1053:14)
debug: TCP communication with hooks handler closed.
warn: Error connecting to the hooks handler process. Is the handler running? Retrying.
verbose: Starting TCP connection with hooks handler process.
debug: TCP communication with hooks handler errored. Error: connect ECONNREFUSED 127.0.0.1:61321
at Object.exports._errnoException (util.js:856:11)
at exports._exceptionWithHostPort (util.js:879:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1053:14)
debug: TCP communication with hooks handler closed.
info: Hooks handler stdout: ./integration/hooks.rb
Starting Ruby Dredd Hooks Worker...
warn: Error connecting to the hooks handler process. Is the handler running? Retrying.
verbose: Starting TCP connection with hooks handler process.
info: Successfully connected to hooks handler. Waiting 0.1s to start testing.
info: Hooks handler stdout: Dredd connected to Ruby Dredd hooks worker
verbose: Registering hooks.
verbose: Executing HTTP transactions.
verbose: Running 'beforeAll' hooks.
debug: Running hooks...
verbose: Sending HTTP transaction data to hooks handler: bf197cce-1ff3-41d5-b8f5-4c03e765f10c
debug: Dredd received some data from hooks handler.
verbose: Dredd received a valid message from hooks handler: bf197cce-1ff3-41d5-b8f5-4c03e765f10c
verbose: Handling hook: bf197cce-1ff3-41d5-b8f5-4c03e765f10c
verbose: Processing transaction #1: Companies > /companies > GET > 200 > application/json; charset=utf-8
verbose: Running 'beforeEach' hooks.
debug: Running hooks...
verbose: Sending HTTP transaction data to hooks handler: 6af4fcec-e97b-48c2-9987-d9391b527e39
debug: Dredd received some data from hooks handler.
verbose: Dredd received a valid message from hooks handler: 6af4fcec-e97b-48c2-9987-d9391b527e39
verbose: Handling hook: 6af4fcec-e97b-48c2-9987-d9391b527e39
verbose: Running 'before' hooks.
verbose: About to perform an HTTP request to tested server.
verbose: Handling HTTP response from tested server.
debug: Response from tested server was recieved.
verbose: Running 'beforeEachValidation' hooks.
debug: Running hooks...
verbose: Sending HTTP transaction data to hooks handler: 24ec5b93-59ba-4990-87d0-c53c99e3218a
debug: Dredd received some data from hooks handler.
verbose: Dredd received a valid message from hooks handler: 24ec5b93-59ba-4990-87d0-c53c99e3218a
verbose: Handling hook: 24ec5b93-59ba-4990-87d0-c53c99e3218a
verbose: Running 'beforeValidation' hooks.
verbose: Validating HTTP transaction by Gavel.js.
debug: Determining whether HTTP transaction is valid (getting boolean verdict).
debug: Validating HTTP transaction (getting verbose validation result).
verbose: Running 'afterEach' hooks.
debug: Running hooks...
verbose: Sending HTTP transaction data to hooks handler: e13fa23b-f8b6-461a-b395-ea6f62ed07b2
debug: Dredd received some data from hooks handler.
debug: Dredd received some data from hooks handler.
verbose: Dredd received a valid message from hooks handler: e13fa23b-f8b6-461a-b395-ea6f62ed07b2
verbose: Handling hook: e13fa23b-f8b6-461a-b395-ea6f62ed07b2
verbose: Running 'after' hooks.
debug: Evaluating results of transaction execution #1: Companies > /companies > GET > 200 > application/json; charset=utf-8
pass: GET /companies duration: NaNms
verbose: Processing transaction #2: Companies > /companies > POST > 201 > application/json; charset=utf-8
verbose: Running 'beforeEach' hooks.
debug: Running hooks...
verbose: Sending HTTP transaction data to hooks handler: 5d1e8404-b40a-46b6-878e-b88e53384169
info: Hooks handler stdout:
debug: Dredd received some data from hooks handler.
verbose: Dredd received a valid message from hooks handler: 5d1e8404-b40a-46b6-878e-b88e53384169
verbose: Handling hook: 5d1e8404-b40a-46b6-878e-b88e53384169
verbose: Running 'before' hooks.
verbose: About to perform an HTTP request to tested server.
verbose: Handling HTTP response from tested server.
debug: Response from tested server was recieved.
verbose: Running 'beforeEachValidation' hooks.
debug: Running hooks...
verbose: Sending HTTP transaction data to hooks handler: 0b2653f6-87d3-4255-a2cd-cc46f44f1741
debug: Dredd received some data from hooks handler.
verbose: Dredd received a valid message from hooks handler: 0b2653f6-87d3-4255-a2cd-cc46f44f1741
verbose: Handling hook: 0b2653f6-87d3-4255-a2cd-cc46f44f1741
verbose: Running 'beforeValidation' hooks.
verbose: Validating HTTP transaction by Gavel.js.
debug: Determining whether HTTP transaction is valid (getting boolean verdict).
debug: Validating HTTP transaction (getting verbose validation result).
fail: POST /companies duration: 22ms
verbose: Running 'afterEach' hooks.
debug: Running hooks...
verbose: Sending HTTP transaction data to hooks handler: 10c0c1e1-c08c-48ce-be0d-6d75ef6ff656
debug: Dredd received some data from hooks handler.
verbose: Dredd received a valid message from hooks handler: 10c0c1e1-c08c-48ce-be0d-6d75ef6ff656
verbose: Handling hook: 10c0c1e1-c08c-48ce-be0d-6d75ef6ff656
verbose: Running 'after' hooks.
debug: Evaluating results of transaction execution #2: Companies > /companies > POST > 201 > application/json; charset=utf-8
verbose: Processing transaction #3: Companies > /companies/{id} > GET > 200 > application/json; charset=utf-8
verbose: Running 'beforeEach' hooks.
debug: Running hooks...
verbose: Sending HTTP transaction data to hooks handler: e9854b93-e985-4902-8b31-716aeab8fccf
debug: Dredd received some data from hooks handler.
verbose: Dredd received a valid message from hooks handler: e9854b93-e985-4902-8b31-716aeab8fccf
verbose: Handling hook: e9854b93-e985-4902-8b31-716aeab8fccf
verbose: Running 'before' hooks.
verbose: About to perform an HTTP request to tested server.
verbose: Handling HTTP response from tested server.
debug: Response from tested server was recieved.
verbose: Running 'beforeEachValidation' hooks.
debug: Running hooks...
verbose: Sending HTTP transaction data to hooks handler: ddf7009c-7917-48cf-a7bd-18da8619166e
debug: Dredd received some data from hooks handler.
verbose: Dredd received a valid message from hooks handler: ddf7009c-7917-48cf-a7bd-18da8619166e
verbose: Handling hook: ddf7009c-7917-48cf-a7bd-18da8619166e
verbose: Running 'beforeValidation' hooks.
verbose: Validating HTTP transaction by Gavel.js.
debug: Determining whether HTTP transaction is valid (getting boolean verdict).
debug: Validating HTTP transaction (getting verbose validation result).
verbose: Running 'afterEach' hooks.
debug: Running hooks...
verbose: Sending HTTP transaction data to hooks handler: 1972c149-713a-4fd7-b416-51aea33164f8
debug: Dredd received some data from hooks handler.
verbose: Dredd received a valid message from hooks handler: 1972c149-713a-4fd7-b416-51aea33164f8
verbose: Handling hook: 1972c149-713a-4fd7-b416-51aea33164f8
verbose: Running 'after' hooks.
debug: Evaluating results of transaction execution #3: Companies > /companies/{id} > GET > 200 > application/json; charset=utf-8
pass: GET /companies/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx duration: NaNms
verbose: Processing transaction #4: Companies > /companies/{id} > PUT > 200 > application/json; charset=utf-8
verbose: Running 'beforeEach' hooks.
debug: Running hooks...
verbose: Sending HTTP transaction data to hooks handler: 5de65e06-5f1f-463b-b5b4-15602be48a21
info: Hooks handler stdout:
debug: Dredd received some data from hooks handler.
verbose: Dredd received a valid message from hooks handler: 5de65e06-5f1f-463b-b5b4-15602be48a21
verbose: Handling hook: 5de65e06-5f1f-463b-b5b4-15602be48a21
verbose: Running 'before' hooks.
verbose: About to perform an HTTP request to tested server.
verbose: Handling HTTP response from tested server.
debug: Response from tested server was recieved.
verbose: Running 'beforeEachValidation' hooks.
debug: Running hooks...
verbose: Sending HTTP transaction data to hooks handler: 287f9cb7-ecbc-472c-a4a6-775d1dc80ab4
debug: Dredd received some data from hooks handler.
verbose: Dredd received a valid message from hooks handler: 287f9cb7-ecbc-472c-a4a6-775d1dc80ab4
verbose: Handling hook: 287f9cb7-ecbc-472c-a4a6-775d1dc80ab4
verbose: Running 'beforeValidation' hooks.
verbose: Validating HTTP transaction by Gavel.js.
debug: Determining whether HTTP transaction is valid (getting boolean verdict).
debug: Validating HTTP transaction (getting verbose validation result).
fail: PUT /companies/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx duration: 21ms
verbose: Running 'afterEach' hooks.
debug: Running hooks...
verbose: Sending HTTP transaction data to hooks handler: 25e2f588-a341-4f86-98ed-7cf4f69352e5
debug: Dredd received some data from hooks handler.
verbose: Dredd received a valid message from hooks handler: 25e2f588-a341-4f86-98ed-7cf4f69352e5
verbose: Handling hook: 25e2f588-a341-4f86-98ed-7cf4f69352e5
verbose: Running 'after' hooks.
debug: Evaluating results of transaction execution #4: Companies > /companies/{id} > PUT > 200 > application/json; charset=utf-8
verbose: Processing transaction #5: Companies > /companies/{id} > DELETE > 200 > application/json; charset=utf-8
verbose: Running 'beforeEach' hooks.
debug: Running hooks...
verbose: Sending HTTP transaction data to hooks handler: 066abd61-cf17-4a3d-89ed-32aa941d8e9d
debug: Dredd received some data from hooks handler.
verbose: Dredd received a valid message from hooks handler: 066abd61-cf17-4a3d-89ed-32aa941d8e9d
verbose: Handling hook: 066abd61-cf17-4a3d-89ed-32aa941d8e9d
verbose: Running 'before' hooks.
verbose: About to perform an HTTP request to tested server.
verbose: Handling HTTP response from tested server.
debug: Response from tested server was recieved.
verbose: Running 'beforeEachValidation' hooks.
debug: Running hooks...
verbose: Sending HTTP transaction data to hooks handler: b477baa1-6a6c-41a2-bcc3-60ddae97bc9a
debug: Dredd received some data from hooks handler.
verbose: Dredd received a valid message from hooks handler: b477baa1-6a6c-41a2-bcc3-60ddae97bc9a
verbose: Handling hook: b477baa1-6a6c-41a2-bcc3-60ddae97bc9a
verbose: Running 'beforeValidation' hooks.
verbose: Validating HTTP transaction by Gavel.js.
debug: Determining whether HTTP transaction is valid (getting boolean verdict).
debug: Validating HTTP transaction (getting verbose validation result).
verbose: Running 'afterEach' hooks.
debug: Running hooks...
verbose: Sending HTTP transaction data to hooks handler: 2d6cda21-7a2a-4d1a-bcc9-d2fa39ec0bb9
debug: Dredd received some data from hooks handler.
verbose: Dredd received a valid message from hooks handler: 2d6cda21-7a2a-4d1a-bcc9-d2fa39ec0bb9
verbose: Handling hook: 2d6cda21-7a2a-4d1a-bcc9-d2fa39ec0bb9
verbose: Running 'after' hooks.
debug: Evaluating results of transaction execution #5: Companies > /companies/{id} > DELETE > 200 > application/json; charset=utf-8
pass: DELETE /companies/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx duration: NaNms
verbose: Running 'afterAll' hooks.
debug: Running hooks...
verbose: Sending HTTP transaction data to hooks handler: 1950bb44-d8c8-454d-9fce-68c71ade5006
debug: Dredd received some data from hooks handler.
debug: Dredd received some data from hooks handler.
debug: Dredd received some data from hooks handler.
verbose: Dredd received a valid message from hooks handler: 1950bb44-d8c8-454d-9fce-68c71ade5006
verbose: Handling hook: 1950bb44-d8c8-454d-9fce-68c71ade5006
verbose: Gracefully terminating hooks handler process.
info: Sending SIGTERM to hooks handler process.
debug: TCP communication with hooks handler closed.
debug: Hooks handler process successfully terminated.
verbose: Wrapping up testing.
info: Displaying failed tests...
fail: POST /companies duration: 22ms
fail: headers: Header 'content-type' is missing
body: Can't validate real media type 'text/plain' against expected media type 'application/schema+json'.
statusCode: Status code is not '201'
debug: Could not stringify:
request:
method: POST
uri: /companies
headers:
Content-Type: application/json
Accept: application/json; charset=utf-8
User-Agent: Dredd/2.2.1 (Darwin 16.1.0; x64)
Authorization: Basic bGFuZXk4MzpwYXNzd29yZA==
body:
expected:
headers:
Content-Type: application/json; charset=utf-8
body:
statusCode: 201
bodySchema: {"properties":{"id":{"type":"string"},"name":{"type":"string","pattern":"[a-zA-Z].*"},"description":{"type":["string","null"]},"phone":{"type":"string"},"website":{"type":"string","format":"url"}},"required":["name","website","phone"]}
actual:
statusCode: 500
headers:
connection: close
content-length: 77
body:
An unhandled lowlevel error occurred. The application logs may have details.
fail: PUT /companies/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx duration: 21ms
fail: headers: Header 'content-type' is missing
body: Can't validate real media type 'text/plain' against expected media type 'application/schema+json'.
statusCode: Status code is not '200'
debug: Could not stringify:
request:
method: PUT
uri: /companies/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
headers:
Content-Type: application/json
Accept: application/json; charset=utf-8
User-Agent: Dredd/2.2.1 (Darwin 16.1.0; x64)
Authorization: Basic bGFuZXk4MzpwYXNzd29yZA==
body:
expected:
headers:
Content-Type: application/json; charset=utf-8
body:
statusCode: 200
bodySchema: {"properties":{"id":{"type":"string"},"name":{"type":"string","pattern":"[a-zA-Z].*"},"description":{"type":["string","null"]},"phone":{"type":"string"},"website":{"type":"string","format":"url"}},"required":["name","website","phone"]}
actual:
statusCode: 500
headers:
connection: close
content-length: 77
body:
An unhandled lowlevel error occurred. The application logs may have details.
complete: 3 passing, 2 failing, 0 errors, 0 skipped, 5 total
complete: Tests took 6148ms
verbose: Dredd instance run finished.
verbose: Exiting Dredd process with status '1'.
debug: Using configured custom exit() method to terminate the Dredd process.
verbose: Gracefully terminating backend server process.
verbose: No backend server process.
After digging further into the problem, i believe the problem is something to do with format: url for the website property.
Thanks for such amazing report! 馃憤
I didn't have much time to dig deeper, but do you think it is the same problem as described in https://github.com/apiaryio/dredd/issues/637#issuecomment-264127407? Would you be willing to experiment and verify whether required works correctly?
I am experiencing the same issue. When testing the exact same swagger yml multiple times, It fails to create a post body on a small percentage of tries. This is sometimes coupled with the same parse error:
(warning code 3) Unable to generate application/json example message body out of JSON Schema
my dredd version output:
dredd v3.0.0 (Darwin 16.4.0; x64)
my swagger (kept very simple for isolating this problem):
swagger: "2.0"
# excluded host info for security
consumes:
- application/json
produces:
- application/json
paths:
/events:
# Store an Event
post:
tags:
- Events
summary: Store a Event
description: Store a Event
consumes:
- application/json
produces:
- application/json
parameters:
- in: body
name: body
description: Event object that needs to be added to storage
required: true
schema:
type: object
properties:
name:
type: string
description: Name of event
city:
type: string
description: City of event
provState:
type: string
description: Province or State of event
startDate:
type: string
format: date
description: Start date of event (YYYY-MM-DD)
endDate:
type: string
format: date
description: End date of event (YYYY-MM-DD)
required:
- name
- city
responses:
"405":
description: Invalid input
"200":
description: Successful post
my command:
dredd dredd_test.yaml http://(hostname)
output:
info: Beginning Dredd testing...
fail: POST /events/api/api/v1/events duration: 270ms
skip: POST /events/api/api/v1/events
info: Displaying failed tests...
fail: POST /events/api/api/v1/events duration: 270ms
fail: body: Can't validate. Expected body Content-Type is application/json but body is not a parseable JSON: Parse error on line 1:
^
Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '[', got 'EOF'
statusCode: Status code is not '200'
request:
method: POST
uri: /events/api/api/v1/events
headers:
Content-Type: application/json
Accept: application/json
User-Agent: Dredd/3.0.0 (Darwin 16.4.0; x64)
Content-Length: 42
body:
{
"name": "Excepteur",
"city": "sit"
}
expected:
headers:
Content-Type: application/json
body:
statusCode: 200
actual:
statusCode: 405
headers:
cache-control: no-cache
x-ratelimit-limit: 60
x-ratelimit-remaining: 58
vary: User-Agent
content-type: application/json
content-length: 180
accept-ranges: bytes
date: Wed, 01 Mar 2017 21:07:57 GMT
connection: close
server: GoalLine
x-xss-protection: 1; mode=block
body:
{
"data": {
"title": "Required Fields Missing",
"error": "The following, required fields are missing from your submission: Province/State, Start Date, End Date, Gender"
},
"status": "405"
}
complete: 0 passing, 1 failing, 0 errors, 1 skipped, 2 total
complete: Tests took 279ms
run again, with NO CHANGES:
warn: Parser warning in file 'dredd_test.yaml': (warning code 3) Unable to generate application/json example message body out of JSON Schema on line 87
warn: Parser warning in file 'dredd_test.yaml': (warning code 3) Unable to generate application/json example message body out of JSON Schema on line 87
info: Beginning Dredd testing...
fail: POST /events/api/api/v1/events duration: 259ms
skip: POST /events/api/api/v1/events
info: Displaying failed tests...
fail: POST /events/api/api/v1/events duration: 259ms
fail: body: Can't validate. Expected body Content-Type is application/json but body is not a parseable JSON: Parse error on line 1:
^
Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '[', got 'EOF'
statusCode: Status code is not '200'
request:
method: POST
uri: /events/api/api/v1/events
headers:
Content-Type: application/json
Accept: application/json
User-Agent: Dredd/3.0.0 (Darwin 16.4.0; x64)
body:
expected:
headers:
Content-Type: application/json
body:
statusCode: 200
actual:
statusCode: 405
headers:
cache-control: no-cache
x-ratelimit-limit: 60
x-ratelimit-remaining: 53
vary: User-Agent
content-type: application/json
content-length: 192
accept-ranges: bytes
date: Wed, 01 Mar 2017 21:06:34 GMT
connection: close
server: GoalLine
x-xss-protection: 1; mode=block
body:
{
"data": {
"title": "Required Fields Missing",
"error": "The following, required fields are missing from your submission: Name, City, Province/State, Start Date, End Date, Gender"
},
"status": "405"
}
complete: 0 passing, 1 failing, 0 errors, 1 skipped, 2 total
complete: Tests took 264ms
I do not believe this is the issue as answered/closed in #637 as mentioned above. I have definitely set 'name' and 'city' as required.
any help appreciated.
Calling @apiaryio/descriptions-team for help 馃檹
@whiskeyseven I am not sure why that is happening. The JSON Schema from your swagger is used by json-schema-faker to generate JSON. Your schema looks straightforward. I don't understand why there is an inconsistency. I need to dig much deeper.
It looks like I have the same issue. Maybe an regression? Here is the relevant snippet:
paths:
/user:
post:
summary: Create new user
parameters:
- name: body
in: body
required: true
schema:
type: object
properties:
email:
type: string
password:
type: string
required:
- email
- password
responses:
201:
description: OK
schema:
$ref: '#/definitions/Ok'
The schema requires email and password and the body parameter is marked as required too, yet the body generated is empty:
request:
method: POST
uri: /api/user
headers:
Accept: application/json
User-Agent: Dredd/3.2.0 (Linux 4.4.0-62-generic; x64)
body:
Okay, I figured it out: I was simply missing 'consumes' definition. Without that, it just doesn't create the body.
Wasn't obvious to me at least.
I think I've figured this out.
thanks to @pksunkara 's hunch about json-schema-faker, I finally went and experimented with my data using a gist. The issue is with the "format" parameter in the schema properties.
See this gist:
http://json-schema-faker.js.org/#gist/2c8648060736ec01329e9ac1d6cd4438
By changing the "date" format value to "date-time", the faker executes correctly. I was seeing strange sporadic behavior because my "date" formatted property was not required, and thus was only included at random. Had I included either of my date fields in the "required" array, my post body would have been blank every time.
Additionally, I checked @CBarraford 's issue, and his hunch was correct. Format "url" causes the same error. Changing the format to "uri" executes normally.
It seems json-schema-faker has not implemented all of the available "format" values specified in the Swagger 2 spec.
Is date and url valid formats under JSON Schema spec?
date is definitely used in the Swagger 2 documentation. I'm not certain about url
I'm having trouble finding a definitive list, to be honest.
json-schema-faker is more concerned about JSON Schema according to their spec. I am not sure if swagger extends JSON schema and adds date format or date is already a format in JSON Schema specification.
It appears the 2 specifications are slightly different, with overlap:
http://swagger.io/specification/
(includes date)
http://json-schema.org/latest/json-schema-validation.html#rfc.section.7
(does not include date but does include email and some other options not explicitly in the swagger specification)
As such, I don't know that this is a "bug" in json-schema-faker (since it does seem to adhere to the json-schema spec), but it does cause an issue with its inclusion in dredd, as dredd is designed to parse valid swagger 2 documents which may contain date
@honzajavorek What do you think about this?
@pksunkara
Okay, I figured it out: I was simply missing 'consumes' definition. Without that, it just doesn't create the body.
AFAIK, swagger spec was supposed to strictly follow JSON Schema but I am wondering if something changed recently. Definitely need to look into this. Can you create a swagger adapter issue for this?
Regarding the consumes definition, I am not sure if we need to do that. We don't create body even in APIB when there's no application/json.
@pksunkara
Regarding the consumes definition, I am not sure if we need to do that. We don't create body even in APIB when there's no
application/json.
I'm wondering whether it would make sense to warn every time the adapter happens not to generate a body. Is there a valid use case when user might want to do exactly that? Maybe we could just note only application/json is supported etc. Give user a hand in writing the Swagger document.
Can you create a swagger adapter issue for this?
Sure: https://github.com/apiaryio/fury-adapter-swagger/issues/99
@honzajavorek I think that's a part of onboarding and documentation rather than parser and error-warnings.