Forum Discussion

LennSar's avatar
LennSar
Contributor
3 years ago

Find correct endpoint for each request in OpenApi Documentation

Hi there,

 

we have a very detailed OpenApi Documentation which we want to take as the basis of our Rest Api tests. ReadyApi so far does a grate job in automatically generating test cases and capturing a lot of possible error. What really bothers me though is that it takes the same endpoint for all requests. While programs such as schemathesis, tcases, insomnia or postman all take the correct endpoint address for each request Ready Api seems to just take the first one it finds in the OpenApi.

Is their any setting that changes this?  

 

Here is some code to add some details:

 

servers:
  - url: 'http://{IP}/api/v-1_0'
    description: http direct
    variables:
      IP:
        default: '169.254.2.0'
        description: IP of the device
  - url: 'https://{IP}/api/v-1_0'
    description: https direct
    variables:
      IP:
        default: '169.254.2.0'
        description: IP of the device

paths:

# expect endpoint 'http://169.254.2.0

  /ping:
    get:
      servers:
      - url: 'http://{IP}'
        description: http direct
        variables:
          IP:
            default: '169.254.2.0'
            description: IP of the device
      summary: dummy text
      description: dummy text
      operationId: Ping
      responses:
        '200':
.
.
.


#---------------------------------------------------------------------------
# /system    expected endpoint:  'http:\\169.254.2.0\api\v-1_0
#---------------------------------------------------------------------------

  /sys/model:
    get:
      summary: dummy text
      description: dummy text.
      operationId: GET_sys/model
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#reference to model schema'
      tags:
        - /system

so what I'd expect is that the ping request would by default be used with the endpoint 'http:\\169.254.2.0' while the \sys\model request would be used with the endpoint 'http:169.254.2.0\api\v-1_0\' instead the endpoint setting in every generated functional test default to 'http:\\169.254.2.0' I can easily change it to the correct one by choosing the right one from the endpoint drop down but that is a paine to do that for all requests and it seems so obsolete as so many other tools do it as I'd expect it. 

Any suggestions are highly appreciated.

 

Thanks!

 

Lenn

 

3 Replies

  • TNeuschwanger's avatar
    TNeuschwanger
    Champion Level 2

    Hello LennSar 

     

    I am no expert at importing OpenAPI specifications so I can only point you to the usage I am familiar with...

     

    Once the testcases are defined in a suite, you can take advantage of the environments feature of ReadyAPI (accessed via the Project|Endpoints & Environments main menu item).  This is where you would define what end point you would like to test against.  You might have to add a variable in your REST test request, but you only do that once and then can use as many environments (end points) as you want.   Refer to: https://support.smartbear.com/readyapi/docs/testing/environments/index.html

     

    You mentioned a few tools ("schemathesis, tcases, insomnia or postman all take the correct endpoint address") that do what you want.  Do you really use all of those?  I occasionally use insomnia just because a vendor we use supplies execution data with it for an API product we purchase from them.  It can only execute the API and is not really a viable testing tool (other than seeing if the API responds or not) that ReadyAPI is.  I feel that comparison (along with the other tools you mention) is unreasonable since the tools are designed and used differently.

     

    Regards,

    Todd

    • LennSar's avatar
      LennSar
      Contributor

      Hi Todd,

       

      thanks for your  suggestion. Sure there is some way to solve this issue using environment variables but I still don't understand why ReadyApi ist not simply doing it right to begin with. 

      We are currently taking a very detailed look at many testing tools to test our Rest APIs. Yes Insomnia isn't comparable with ReadyApi from a testing capability persepective but they both are reading an OpenApi and are able to generate the according requests which can be send by a push of a button. After that the magic of ReadyApi starts but up to that point I think they are very comparable. 

      I just took another look and had to realize that postman and insomnia don't understand my OpenApi in regards of the base URL as well. But other than ReadyApi they correclty understand the description of the "global" server address and don't use the first request specific URL for all requests, which is quite a headscratcher.

       

      I'll have a closer look at environment variables defined in the OpenApi spec but to my understanding we are already doing it correctly from an OpenApi perspective.