swagger-api / swagger-api/swagger-codegen

[C#] Unable to build target: Could not process model '...' with allOf and enum

Open
#3,338 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Client: C-Sharp Feature: Composition / Inheritance Feature: Enum Issue: Bug Issue: Workaround available
Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

When using embedded Swagger Code Gen in Swagger Editor, trying to generate C# Client Code, I get an "could not process model" error. I located the error down, and it seems that the generator has a problem with properties using "allOf" and enums.

example:

swagger: '2.0'
info:
  version: 1.0.0
  title: Example API
  description: |
    blabla
  termsOfService: Copyright TEST eG - 2015
  contact:
    name: info@example.de
  license:
    name: Test eG
    url: www.Test.de  

host: localhost:58454
basePath: /test/api
schemes:
 - http
consumes:
 - application/json;charset=utf-8
produces:
 - application/json;charset=utf-8  

paths:

  /core/v1/test/:
    get:
      tags: 
        - 1 tester 
      summary: Test Summary 
      description: |



        descriptiontext

      responses:
        '200':
          description: Success.
          headers:
            RequestId:
              type: string
              description: Request id
          schema: 
            type: array
            items: 
              $ref: '#/definitions/allOfTest'


definitions:

  allOfTest:
    allOf: 
    - $ref: '#/definitions/referenceTest'
    type: object


  referenceTest:
    type: object
    properties:
      enum_type:
        type: string
        enum:
          - a
          - b
          - c
          - d
          - e
          - f
        description: | 
            descriptiontext

error:

Unable to build target: Could not process model 'allOfTest'

Details:

►  Object   

 code:  1 

 type:  "error" 

 message:  "Unable to build target: Could not process model 'allOfTest'" 

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with embedded Swagger Code Gen's C# client generation and reproduce the failure using the supplied Swagger 2.0 definition, focusing on the allOfTest and referenceTest models. The work is done when the example generates a C# client without the 'Could not process model' error.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.