Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #592
Closed
Open
Issue created Jul 18, 2018 by Administrator@rootContributor

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.

Assignee
Assign to
Time tracking