-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
In the file modules/openapi-generator/src/main/resources/csharp-netcore/modelGeneric.mustache the IValidatableObject interface is implemented when required, but purposefully hidden. The models get generated with the interface, and the code, but as it's set to private it can't be used.
(Note: The issue can be easily be fixed locally with a custom template. This issue is mostly to understand how this happened, and if there is a purpose to it.)
openapi-generator version
5.2.1
OpenAPI declaration file content or url
Snippet schema of a model that has this issue:
components:
schemas:
ClockRate:
type: integer
format: int
description: clock rate
example: 90000
default: 90000
NewStreamRequest:
type: object
properties:
clockRate:
$ref: '#/components/schemas/ClockRate'Generation Details
Was encountered using the csharp-netcore generator, and the latest-release docker image.
Steps to reproduce
Using a yaml file that contains a model what can be validated
docker run --rm -v %cd%:/local openapitools/openapi-generator-cli:latest-release generate ^
-i /local/openapi.yaml ^
-g csharp-netcore ^
-o /local/output/openapi
Related issues/PRs
Suggest a fix
In the file modules/openapi-generator/src/main/resources/csharp-netcore/modelGeneric.mustache change line 399 and 418 from
IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
to
public IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> Validate(ValidationContext validationContext)