Forum Discussion

krogold's avatar
krogold
Regular Contributor
3 years ago

get swagger ident from groovy script

Hi,

In my project, I import a swagger (.yaml) file to do definition update.

I would like to know if it is possible to get its identification from a groovy step ? ie. in my resources / Specification tag, I can see my Original definition path, this is the information I would like to get with a groovy script

  • Well, finally I found it : when you get your interface's data (your APIs)

     

    restServiceList = testRunner.testCase.testSuite.project.getInterfaceList()

     

     

    and you select the one you want (I have two of them), then you can identify the context and get the url

     

    restServiceList.each{
        interface ->
        if (interface.getName() == "myInterfaceName")
        {
           myContext = interface .getDefinitionContext()
           log.info myContext.url // ==> gives you the swagger's path
        }
    }

     





  • krogold's avatar
    krogold
    Regular Contributor

    Well, finally I found it : when you get your interface's data (your APIs)

     

    restServiceList = testRunner.testCase.testSuite.project.getInterfaceList()

     

     

    and you select the one you want (I have two of them), then you can identify the context and get the url

     

    restServiceList.each{
        interface ->
        if (interface.getName() == "myInterfaceName")
        {
           myContext = interface .getDefinitionContext()
           log.info myContext.url // ==> gives you the swagger's path
        }
    }