swagger-api / swagger-api/swagger-codegen

Broken C# generated using swagger spec

Open
#12,007 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

Q&A
  • OS: Windows 10 (21H2)
  • Browser: Microsoft Edge
  • Version: 108
  • Method of installation: N/A - editor.swagger.io
  • Swagger-Editor version: latest as of post (no idea where it shows this)
  • Swagger/OpenAPI version: latest as of post (no idea where it shows this)
Content & configuration

Example Swagger/OpenAPI definition:
https://sellerapi.kaufland.com/swagger.json

Swagger-Editor configuration options:
Default settings

?_ga=2.158309177.205868905.1671524195-1419130726.1669876810
Describe the bug you're encountering

Generates broken C#

  • Comment lines in XML documentation do not start with // when there's a new line in param node (e.g. ln 199 \src\IO.Swagger\Api\ProductDataApi.cs)
  • Null default value assignment to non-nullable types (enums) (e.g. ln 1253 \src\IO.Swagger\Api\ProductDataApi.cs)
  • Inheritance of unknown types Integer, LongInteger (e.g. ln 30 \src\IO.Swagger\Model\AllOfOrderDetailsOrderUnitsDeliveryTimeMin.cs)
  • Inheritance of enums (e.g. ln 30 src\IO.Swagger\Model\AllOfTicketTopic.cs)
  • Probably more, Visual Studio not showing all errors
To reproduce...

Steps to reproduce the behavior:

  1. Generate regular C# client on editor.swagger.io with default settings using swagger spec: https://sellerapi.kaufland.com/swagger.json
  2. Open solution and observe mountain of errors
Expected behavior

Valid C#

Screenshots

image
image
image
image

Additional context or thoughts

-

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 by reproducing generation from the linked sellerapi.kaufland.com/swagger.json with the default editor.swagger.io settings. Inspect the generated ProductDataApi.cs and the AllOfOrderDetailsOrderUnitsDeliveryTimeMin.cs and AllOfTicketTopic.cs models for the reported documentation, nullability, unknown-type, and enum-inheritance errors. Done means the generated C# solution builds without these errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 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.