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
  • Merge requests
  • !2897

[core] Support case where composed schema is single type definition

  • Review changes

  • Download
  • Email patches
  • Plain diff
Open Administrator requested to merge github/fork/fantavlik/enum-anyof into master May 15, 2019
  • Overview 0
  • Commits 2
  • Pipelines 1
  • Changes 1

Created by: fantavlik

Description of the PR

Fix for https://github.com/OpenAPITools/openapi-generator/issues/2164

The general fix is to handle the case where a composed schema is a single element defining a type.

For example:

allOf/anyOf/oneOf:
  - type: string

^ this case is not really model composition but rather defining the type of the model which is equivalent to type: <>

Input:

components:
  schemas:
    RatType:
      anyOf:
      - type: string
      enum:
        - NR
        - EUTRA
        - WLAN
        - VIRTUAL
      type: string

Output for Go model_rat_type.go:

package openapi
type RatType string

// List of RatType
const (
	NR RatType = "NR"
	EUTRA RatType = "EUTRA"
	WLAN RatType = "WLAN"
	VIRTUAL RatType = "VIRTUAL"
)

@wing328 can you review this if you get a moment as it is a core change? I've tested Go and regenerated the sample files and there are no changes for Go at least, not sure about other languages.

cc: @mroland91 and @goyalnikhil

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/fantavlik/enum-anyof