-
Notifications
You must be signed in to change notification settings - Fork 6k
Description
Description
I'm using server templating in my swagger.yaml and swagger-codegen-cli-3.0.21 JAR file to generate a Python SDK. In the generated configuration.py file, the host is populated as a string with the placeholders rather than being substituted. This consequently returns "name or service unknown" error when the client tries to connect to the host
Swagger-codegen version
swagger-codegen-cli-3.0.21
Swagger declaration file content or url
openapi: 3.0.0
info:
title: my model
version: '1.0'
servers:
- url: '{protocol}://{server}/{basePath}'
variables:
protocol:
enum:
- http
- https
default: http
server:
enum:
- localhost:1234
- prod_server
default: localhost:1234
basePath:
default: v1/mymodelCommand line used for generation
java -jar swagger-codegen-cli-3.0.21 generate -i myclient/swagger.yaml -o myclient/ -l python
Steps to reproduce
run command line above, returns configuration.py with:
self.host = "{protocol}://{server}/{basePath}"Related issues/PRs
Suggest a fix/enhancement
have codegen perform variable substitution on the default values and populate host accordingly in configuration.py. Similar functionality has been implemented in OpenAPI generator which handles both multiple servers and variable substitution