swagger-api / swagger-api/swagger-codegen

c# asp.net 4.* server generation support

Open
#9,355 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'd like to get Models and Controllers to be generated for Asp.Net 4.* framework. Unfortunately current Asp.net Core generator produces incompatible code, like namespaces and types that exists in the .Net Core framework only.

There is a need to implement REST service for the legacy .Net 4.7.2 project and client is using .Net Core 2 framework. So I'd like to use the same yaml to generate client and server from the one source

Models source code can be compiled for .Net Framework 4 as is but not Controllers.

I've tried to modify generated controllers source code to be compiled using .Net Core and .Net Framework but failed. I can't get deal with Core specific type usage, like IActionResult and Swashbuckle.AspNetCore.SwaggerGen namespace even using #if NETCOREAPP2_0 .

Swagger-codegen version

2.4.5

Related issues/PRs

#7114

Suggest a fix/enhancement

I'm going to add AspNet4ServerGenerator class and copy mustache templates. Hope server source code will be compiled using .Net 4.7.2
Not sure that will be able to implement Swashbuckle metadata descriptions to provide web interface description.

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 the existing ASP.NET Core server generator and its Mustache templates, then review the proposed AspNet4ServerGenerator approach. Confirm which generated controllers and framework-specific types prevent compilation for .NET Framework 4.7.2. Done means Models and Controllers generated from the same YAML compile for the legacy framework; Swagger metadata support is noted as unresolved in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api, backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.