1

this may be trivial question, but I am having problems understanding server variables and how to modify them on swagger.

My objective is to create a server using the specs below (5G 3gpp definitions for of its interfaces).

https://www.3gpp.org/ftp/Specs/archive/OpenAPI/Rel-16/TS29122_PfdManagement.yaml.

As you can see at the top of this file we have a server variable called apiRoot which defines the root of the url of the server. That is set up to default value of example.com. That url will later be used by swagger-ui to provide a graphic interface to the API.

servers:
  - url: '{apiRoot}/nnef-eventexposure/v1'
    variables:
      apiRoot:
        default: https://example.com
        description: apiRoot as defined in clause 4.4 of 3GPP TS 29.501

I am trying to generate the server with the swagger-codegen which generates a consolidated file with all the elements this spec needs (since the original yaml file contains references to other files)

swagger-codegen generate -i  https://www.3gpp.org/ftp/Specs/archive/OpenAPI/Rel-16/TS29122_PfdManagement.yaml   -l go-server -o server

The problem is the file embeds the default value. So I can not use that file on multiple hosts.

Is there any way to modify variable apiRoot when executing swagger-codegen? Or even better, is there any way to change the value of the default using some kind of envar? Or is there any way to pass swagger the value of apiRoot

The idea is we can use the same specs in different servers without having to modify the original spec file or the generated one. The problem with modifying the yaml files is that there will be more versions comming from 3gpp which will include apiRoot variable, so we don't wang to keep modifying every single time. We would like to overwrite it somehow on runtime.

Ob200
  • 11
  • 2

0 Answers0