Forum Discussion

pricedgp's avatar
pricedgp
Contributor
3 years ago

Property expansion for OpenAPI definition (REST) yaml file location

I have .yaml definitions for REST services that I use when importing API definitions. This works fine when I point to the yaml file on disk and import it. However, I'd rather not hard-code the path, because when other people use the project in their environment, their path will be different.

 

I've used property expansion in the past for WSDLs, but haven't done it for REST definitions. I'd like to do something like this:

 

${openApiBaseUri}/myDefinition.yaml

 

where openApiBaseUri is a global property that points to the directory where the OpenAPI definitions live.

 

When I try this, I get this error:

 

ERROR: unable to read location `${openApiBaseUri}/myDefinition.yaml`

 

Any ideas? We can't afford SwaggerHub, so I'm looking for a generic solution. 

 

Thanks,

 

  • KarelHusa's avatar
    KarelHusa
    Champion Level 1

    pricedgp,

    I am not sure what is your use case. When you do a composition of multiple OpenAPI files (yaml/json), you can use relative paths. You do not need to hold the absolute path in such a case.

     

    If you describe in more detail what you want to achieve, we can come up with some further suggestions.

     

    • pricedgp's avatar
      pricedgp
      Contributor

      I use a global property file for many things. In this case, I want to use it to indicate the base directory where the API definitions (yaml files) are located.

       

      In other words, if I give my project to another user, the API definitions are still pointing to my local directory.  I'd like to use a "base directory" global variable which will resolve to each person's directory, where they store the yaml files. When that person clicks on a REST API and selects "Update Definition," it should look something like this:

      ${baseYamlDirectory}/data-service/openapi/myApiDefinition.yaml

       

      but instead, it's hard coded, like this:

      file:/C:/Users/myName/Documents/hebb/data-service/openapi/myApiDefinition.yaml

       

      Is there a way to do what I'm trying to do? (ReadyAPI 3.10.1)

       

  • Unfortunately, it seems 3.10.1 is a bit buggy with respect to this -- filed a support request. Have tried simplifying the problem such that every engineer will store the yaml files in a specific location on their C drive (C:\openapi). 

     

    But even my simple solution doesn't work. If I select Update Definition and browse to that location, and save everything, when I open the project again and select Update Definition, the UI shows it as blank. But, in the settings file for that API, the definitionUrl property shows a different name. (I may pose this as a different question in this forum -- surely I'm missing something).