Closed rahulahoop closed 2 years ago
@rahulahoop this is fixed in the last commit and will be released this week.
Ok I've built the jar from source and now Im getting the error stack trace.
i softlinked the jar so i can run it anywhere but the first stack trace i got was file not found becuase im giving the file relative to the dir im in, so like in the example
dir
$dir cats.jar --contract=spec
if i provide full PWD then he finds the file.
Then he cant interpret references to other yaml files and throws a npe:
[**********][*****] Exception while resolving:
java.lang.RuntimeException: Unable to load RELATIVE ref: ./schemas/shared.yaml path: .
at io.swagger.v3.parser.util.RefUtils.readExternalRef(RefUtils.java:239)
is this not supported?
@en-milie
@rahulahoop Is it possible to post an example? It seems that the openapi parser has issues with this. I didn't test this scenario yet, so it will be helpful to see what's missing. It might be some additional parser configuration that's needed.
its correct in reading from an external file, perhaps its the path
am i incorrect in providing the full qualified path for the contract?
I'll run the example and get back
@rahulahoop you should put $ref: './shared/extra.yaml/#/components/schemas/NotAccessible'
. Please notice the ./
at the start.
@en-milie i still get runtime exception with the same error
I run CATS as:
./cats.jar --contract=contract.yaml --server=http://localhost:8200
The contract.yaml looks as follows:
openapi: "3.0.2"
info:
title: API Title
version: "1.0"
servers:
- url: https://api.server.test/v1
paths:
/test:
get:
responses:
'200':
description: OK
components:
schemas:
InFileObject:
type: object
properties:
Acessable:
type: string
OutFileObject:
$ref: './shared/extra.yaml/#/components/schemas/NotAccessible'
And I get a full run:
☑ complete CATS finished in 2151 ms. Total (excluding skipped) requests 66. ✔ Passed 3, ⚠ warnings: 22, ‼ errors: 41,
@rahulahoop am I missing something?
@rahulahoop can I close this? or still having issues?
I am still having an issue but Im not sure how I can recreate it.
I moved the jar to folder of my specification and he starts to fuzz with happyfuzzer but gets a null pointer on endpoint that looks like this
[**********][*****] ▶ start Start fuzzing path /statistics/bk/{subtype}
[**********][*****] ✖ error Something went wrong while running CATS!
java.lang.NullPointerException: null
at com.endava.cats.generator.simple.PayloadGenerator.parseFromInnerSchema(PayloadGenerator.java:338)
/statistics/bk/{subtype}:
get:
summary: Return statistics for BK case
description: Returns the yearly statistics for BK cases. If no search parameter is given the
current year will be used.
operationId: get-statistics-bk
parameters:
- in: path
name: subtype
required: true
schema:
$ref: 'schemas/statistics-reports.yaml#/components/schemas/StatisticBKSubtype'
- name: year
in: query
required: false
schema:
type: integer
tags:
- statistics
- BK
responses:
200:
$ref: '#/components/responses/StatisticDataResponse'
404:
description: No statistics for chosen year found
i tried to make a smaller replica case for this but its not getting npe so im a little bit confused
@rahulahoop will you be able to post the schemas as well? both of them? (anonymised, of course)
@en-milie sure i think its with the subtype tho
StatisticBKSubtype:
type: string
enum:
- UNKNOWN
- GRANT
- REJECT
- INQUERY
responses:
StatisticDataResponse:
description: Returns the statistics for the chosen year
content:
application/json:
schema:
$ref: 'schemas/statistics-reports.yaml#/components/schemas/StatisticYear'
# another file...
StatisticYear:
type: object
properties:
year:
type: integer
months:
type: array
items:
$ref: '#/components/schemas/StatisticMonth'
maxItems: 12
default: []
required:
- year
- months
@rahulahoop I did a run with the following schemas and didn't reproduce the problem. From the exception you mentioned above it seems that you use anyOf
or oneOf
with a discriminator. Can you also let me know where is that used?
statistics.yaml
openapi: "3.0.2"
info:
title: API Title
version: "1.0"
servers:
- url: https://api.server.test/v1
paths:
/statistics/bk/{subtype}:
get:
summary: Return statistics for BK case
description: Returns the yearly statistics for BK cases. If no search parameter is given the
current year will be used.
operationId: get-statistics-bk
parameters:
- in: path
name: subtype
required: true
schema:
$ref: 'schemas/statistics-reports.yaml#/components/schemas/StatisticBKSubtype'
- name: year
in: query
required: false
schema:
type: integer
tags:
- statistics
- BK
responses:
200:
$ref: '#/components/responses/StatisticDataResponse'
404:
description: No statistics for chosen year found
components:
responses:
StatisticDataResponse:
description: Returns the statistics for the chosen year
content:
application/json:
schema:
$ref: 'schemas/statistics-reports.yaml#/components/schemas/StatisticYear'
statistics-reports.yaml:
openapi: "3.0.2"
info:
title: API Title
version: "1.0"
servers:
- url: https://api.server.test/v1
paths:
/test:
get:
responses:
'200':
description: OK
components:
schemas:
StatisticMonth:
type: object
properties:
month:
type: integer
day:
type: integer
StatisticYear:
type: object
properties:
year:
type: integer
months:
type: array
items:
$ref: '#/components/schemas/StatisticMonth'
maxItems: 12
default: [ ]
required:
- year
- months
StatisticBKSubtype:
type: string
enum:
- UNKNOWN
- GRANT
- REJECT
- INQUERY
@rahulahoop can I close this one? and maybe open a new one for the issue(s) you are facing?
@en-milie sure thats a good idea
When trying to run cats on our project specification, i get a plain old
[**********][*****] ‼ fatal Error parsing OPEN API contract <filename>
anyway could get a reasoning with whats wrong in the error message ?
we are using relative file paths to reference and reuse schema definitions.
ive added cats.jar to my path so i can run it directly on the project level