Code Monkey home page Code Monkey logo

Comments (16)

en-milie avatar en-milie commented on May 28, 2024 1

I'll run the example and get back

from cats.

en-milie avatar en-milie commented on May 28, 2024

@rahulahoop this is fixed in the last commit and will be released this week.

from cats.

rahulahoop avatar rahulahoop commented on May 28, 2024

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

  • spec

$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

from cats.

en-milie avatar en-milie commented on May 28, 2024

@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.

from cats.

rahulahoop avatar rahulahoop commented on May 28, 2024

example.zip

attached is a sample of referencing the path

produces the same error

@en-milie

from cats.

rahulahoop avatar rahulahoop commented on May 28, 2024

https://github.com/swagger-api/swagger-parser/blob/2de0106e4502d6db72848f5a8daad13a7e572b98/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/ResolverCache.java#L126

its correct in reading from an external file, perhaps its the path

am i incorrect in providing the full qualified path for the contract?

from cats.

en-milie avatar en-milie commented on May 28, 2024

@rahulahoop you should put $ref: './shared/extra.yaml/#/components/schemas/NotAccessible'. Please notice the ./ at the start.

from cats.

rahulahoop avatar rahulahoop commented on May 28, 2024

@en-milie i still get runtime exception with the same error

from cats.

en-milie avatar en-milie commented on May 28, 2024

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?

from cats.

en-milie avatar en-milie commented on May 28, 2024

@rahulahoop can I close this? or still having issues?

from cats.

rahulahoop avatar rahulahoop commented on May 28, 2024

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

from cats.

en-milie avatar en-milie commented on May 28, 2024

@rahulahoop will you be able to post the schemas as well? both of them? (anonymised, of course)

from cats.

rahulahoop avatar rahulahoop commented on May 28, 2024

@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

from cats.

en-milie avatar en-milie commented on May 28, 2024

@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

from cats.

en-milie avatar en-milie commented on May 28, 2024

@rahulahoop can I close this one? and maybe open a new one for the issue(s) you are facing?

from cats.

rahulahoop avatar rahulahoop commented on May 28, 2024

@en-milie sure thats a good idea

from cats.

Related Issues (20)

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.