Skip to content

[BUG][aspnetcore] Virtual and abstract not used correctly #7042

Open
@Sshnyari

Description

@Sshnyari

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

In the server generated code for aspnetcore:

  1. When using the 'generateBody' option to false, we get a virtual method with no body. It should be an abstract method if the method have no body, and the class should also be made abstract in this case.

  2. When using the 'operationModifier', we get abstract methods, but not an abstract class. The class should also be abstract for it to work.

Also, unless I am mistaken, it seems that these two options (generateBody and operationModifier) have the same purpose

openapi-generator version

4.3.1

OpenAPI declaration file content or url

can be reproduced with the petstore file

Command line used for generation

openapi-generator generate -g aspnetcore -i petstore.json -c config.json -o src
and one of the following config.json files can be used depending on the case (1 or 2)

{
	"aspnetCoreVersion":"3.1",
	"operationModifier": "abstract"
}

or

{
	"aspnetCoreVersion":"3.1",
	"generateBody": false
}
Steps to reproduce

just running the command is enough to see the results

Related issues/PRs
Suggest a fix

changing virtual with abstract when relevant and adding abstract to the class when methods are abstract

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions