You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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
The text was updated successfully, but these errors were encountered:
@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.JavaClientCodegen", date = "2020-11-02T12:34:38.995686-08:00[America/Los_Angeles]")@Component("myapp.ApiClient")
publicclassApiClient {
publicenumCollectionFormat {
CSV(","), TSV("\t"), SSV(" "), PIPES("|"), MULTI(null);
privatefinalStringseparator;
privateCollectionFormat(Stringseparator) {
this.separator = separator;
}
privateStringcollectionToString(Collection<? extendsCharSequence> collection) {
returnStringUtils.collectionToDelimitedString(collection, separator);
}
}
privatebooleandebugging = false;
privateHttpHeadersdefaultHeaders = newHttpHeaders();
privateStringbasePath = "{protocol}://myapp.com";
privateRestTemplaterestTemplate;
privateMap<String, Authentication> authentications;
privateHttpStatusstatusCode;
privateMultiValueMap<String, String> responseHeaders;
privateDateFormatdateFormat;
publicApiClient() {
this.restTemplate = buildRestTemplate();
init();
}
@AutowiredpublicApiClient(RestTemplaterestTemplate) {
this.restTemplate = restTemplate;
init();
}
protectedvoidinit() {
// Use RFC3339 format for date and datetime.// See http://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14this.dateFormat = newRFC3339DateFormat();
// Use UTC as the default time zone.this.dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
// Set default User-Agent.setUserAgent("Java-SDK");
// Setup authentications (key: authentication name, value: authentication).authentications = newHashMap<String, Authentication>();
// Prevent the authentications from being modified.authentications = Collections.unmodifiableMap(authentications);
}
/** * Get the current base path * @return String the base path */publicStringgetBasePath() {
returnbasePath;
}
/** * Set the base path, which should include the host * @param basePath the base path * @return ApiClient this client */publicApiClientsetBasePath(StringbasePath) {
this.basePath = basePath;
returnthis;
}
...
Uh oh!
There was an error while loading. Please reload this page.
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
Command 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:
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
The text was updated successfully, but these errors were encountered: