swagger-api / swagger-api/swagger-codegen
[C#] Not full Validation method
Open
Nobody has claimed this yet.
Client: C-Sharp
Issue: Bug
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Hi, all
I found some problems with Validation method.
For YAML:
definitions:
Parameter:
type: object
required:
- Value
- ArrayValue
properties:
Value:
type: integer
minimum: 3
maximum: 5
ArrayValue:
type: array
minItems: 3
maxItems: 5
items:
type: integer
Validation method:
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
// Value (int?) maximum
if(this.Value > (int?)5.0)
{
yield return new ValidationResult("Invalid value for Value, must be a value less than or equal to 5.0.", new [] { "Value" });
}
// Value (int?) minimum
if(this.Value < (int?)3.0)
{
yield return new ValidationResult("Invalid value for Value, must be a value greater than or equal to 3.0.", new [] { "Value" });
}
yield break;
}
There is no:
- Check properties for null (properties are required!)
- There is no
minItems,maxItemsvalidation !
PS: Our company use full PAID SwaggerHub subscription and we do not interested in using any branches or somethins else. Only stable Web SwaggerHub interface!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the reported YAML input and inspect the generated C# Validation method, since no source file or test is identified in the issue. Done means required properties are checked for null and array properties enforce minItems and maxItems, alongside the existing numeric validation.
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
- Needs clarification
- Newbie friendliness
- 35/100