swagger-api / swagger-api/swagger-codegen

[CSharp] Could not process model bug

Open
#7,183 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

I use simple YAML (JSON tested too) and have a problem with clients generation.

The error:

[main] INFO io.swagger.parser.Swagger20Parser - reading from ./swaggers/build.yaml
[main] INFO io.swagger.codegen.languages.CSharpClientCodegen - Generating code for .NET Framework v4.5
Exception in thread "main" java.lang.RuntimeException: Could not process model 'BranchConfiguration'.Please make sure that your schema is correct!
        at io.swagger.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:328)
        at io.swagger.codegen.DefaultGenerator.generate(DefaultGenerator.java:697)
        at io.swagger.codegen.cmd.Generate.run(Generate.java:285)
        at io.swagger.codegen.SwaggerCodegen.main(SwaggerCodegen.java:35)
Caused by: java.lang.NullPointerException
        at io.swagger.codegen.DefaultCodegen.fromModel(DefaultCodegen.java:1284)
        at io.swagger.codegen.languages.CSharpClientCodegen.fromModel(CSharpClientCodegen.java:430)
        at io.swagger.codegen.DefaultCodegen.fromModel(DefaultCodegen.java:1266)
        at io.swagger.codegen.languages.CSharpClientCodegen.fromModel(CSharpClientCodegen.java:433)
        at io.swagger.codegen.DefaultGenerator.processModels(DefaultGenerator.java:939)
        at io.swagger.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:323)
        ... 3 more
Swagger-codegen version

Latest, 2.2.3 version

Swagger declaration file
swagger: '2.0'
host: api.appcenter.ms
basePath: /
schemes:
  - https
consumes:
  - application/json
produces:
  - application/json
paths:
  '/v0.1/apps/{owner_name}/{app_name}/branches/{branch}/config':
    get:
      responses:
        '200':
          schema:
            $ref: '#/definitions/BranchConfiguration'
      operationId: branchConfigurations_get
      tags:
        - build
definitions:
  BranchConfiguration:
    properties:
      trigger:
        type: string
        enum:
          - continuous
          - manual
    additionalProperties:
      $ref: '#/definitions/BranchProperties'
  BranchProperties:
    properties:
      enabled:
        type: boolean
Command line used for generation

swagger-codegen generate -i ./swagger.yaml -l csharp -o ./clients/swagger-codegen-csharp

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

Reproduce the failure with the supplied Swagger YAML and the swagger-codegen generate command, then trace the stack from DefaultCodegen.fromModel through CSharpClientCodegen.fromModel. Use the BranchConfiguration and BranchProperties definitions as the focused case; done means C# model generation completes without the reported NullPointerException.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.