Support variables in server URLs for OAS 3.x
Created by: haitongz
Description
When running generator on an openapi 3.x document, if you use a variable for the port, generator print a warning. The warning does not block the generation, but does support openapi 3.x new feature. In addition it use default value instead in this circumstance.
Error looks like:
[main] WARN o.o.codegen.utils.URLPathUtils - Not valid URL: http://example.com:{port}/v1. Default to http://localhost.
openapi-generator version
OpenAPI Generator 3.1.0
OpenAPI declaration file content or url
Command line used for generation
openapi-generator generate -i sample.yaml -g python -o /tmp/test1/
Steps to reproduce
can use yaml from: https://raw.githubusercontent.com/douglasbgray/code-gen-server-issue/master/src/main/resources/openapi.yaml
Related issues/PRs
Did not find any open issues related to this, but find related from swagger-codegen: https://github.com/swagger-api/swagger-codegen/issues/8412
Suggest a fix/enhancement
Error is coming from URLPathUtil.java. Before checking if the url can be converted into a java.net.URL, it needs to perform the variable substitution, which would resolve the {port} and generate a URL that would be valid. I find the source code URLPathUtil.java added TODO comments(TODO need a way to obtain all server URLs). I am not familiar with java. How I can finish the task myself? thanks for your great job.