Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception thrown when using number type with only minimum part of range validation specified #107

Open
cjakobsen opened this issue May 28, 2021 · 0 comments

Comments

@cjakobsen
Copy link
Contributor

Description
If a property is defined as a number and range validation is specified but only using the minimum property an exception is thrown during generation of the api.

To Reproduce
Steps to reproduce the behavior:

  1. Modify the sample project to have the beflow definition for the Order type where myNumber only has minimum specified:
  2. Run the generator
  3. The following error is returned: "Cannot parse value as number (Parameter 'value')"

Expected behavior
Code is generated with range validation from specified minimum (1.1) to infinite.

Order definition

    Order:
      title: Order
      description: |-
        A single order.
        Hallo description with multiline and no ending dot
      type: object
      x-examples:
        MyExample:
          id: 123
          name: Hallo world
        MyExample2: {}
      properties:
        id:
          type: string
          format: uuid
        description:
          type: string
        myTime:
          type: string
          format: time
        myEmail:
          type: string
          format: email
          default: [email protected]
        myNullableDateTime:
          type: string
          format: date-time
          nullable: true
        myDateTime:
          type: string
          format: date-time
        myNumber:
          type: number
          minimum: 1.1
        myInteger:
          type: integer
          maximum: 50
          default: 15
        myBool:
          type: boolean
          description: MyBool is great
        myUri:
          type: string
          format: uri
          description: 'This is the good uri :-)'
        myByte:
          type: string
          format: byte
        myStringList:
          type: array
          description: 'Hallo myStringList desc :-)'
          items:
            type: string
        myLong:
          type: integer
          format: int64
          minimum: 10
          exclusiveMinimum: false
        deliveryAddress:
          $ref: '#/components/schemas/Address'

Exception details

   at Atc.CodeAnalysis.CSharp.SyntaxFactories.SyntaxLiteralExpressionFactory.Create(String value, SyntaxKind syntaxKind) in /_/src/Atc.CodeAnalysis.CSharp/SyntaxFactories/SyntaxLiteralExpressionFactory.cs:line 35
   at Atc.CodeAnalysis.CSharp.SyntaxFactories.SyntaxAttributeArgumentFactory.Create(Object attributeValue) in /_/src/Atc.CodeAnalysis.CSharp/SyntaxFactories/SyntaxAttributeArgumentFactory.cs:line 26
   at Atc.CodeAnalysis.CSharp.SyntaxFactories.SyntaxAttributeFactory.CreateWithOneItemWithTwoArgument(String attributeName, Object argumentValue1, Object argumentValue2) in /_/src/Atc.CodeAnalysis.CSharp/SyntaxFactories/SyntaxAttributeFactory.cs:line 68
   at Atc.CodeAnalysis.CSharp.SyntaxFactories.SyntaxAttributeFactory.CreateFromValidationAttribute(ValidationAttribute validationAttribute) in /_/src/Atc.CodeAnalysis.CSharp/SyntaxFactories/SyntaxAttributeFactory.cs:line 92
   at Atc.CodeAnalysis.CSharp.PropertyDeclarationSyntaxExtensions.AddValidationAttribute(PropertyDeclarationSyntax propertyDeclaration, ValidationAttribute validationAttribute) in D:\Work\GitHub\atc-rest-api-generator\src\Atc.Rest.ApiGenerator\Extensions\PropertyDeclarationSyntaxExtensions.cs:line 99
   at Atc.CodeAnalysis.CSharp.PropertyDeclarationSyntaxExtensions.RangeAttributeDouble(PropertyDeclarationSyntax propertyDeclaration, OpenApiSchema schema) in D:\Work\GitHub\atc-rest-api-generator\src\Atc.Rest.ApiGenerator\Extensions\PropertyDeclarationSyntaxExtensions.cs:line 311
   at Atc.CodeAnalysis.CSharp.PropertyDeclarationSyntaxExtensions.AddValidationAttributeForMinMaxIfRequired(PropertyDeclarationSyntax propertyDeclaration, OpenApiSchema schema) in D:\Work\GitHub\atc-rest-api-generator\src\Atc.Rest.ApiGenerator\Extensions\PropertyDeclarationSyntaxExtensions.cs:line 190
   at Atc.Rest.ApiGenerator.SyntaxFactories.SyntaxPropertyDeclarationFactory.CreateAuto(KeyValuePair`2 schema, ISet`1 requiredProperties, Boolean useNullableReferenceTypes) in D:\Work\GitHub\atc-rest-api-generator\src\Atc.Rest.ApiGenerator\SyntaxFactories\SyntaxPropertyDeclarationFactory.cs:line 115
   at Atc.Rest.ApiGenerator.SyntaxGenerators.Api.SyntaxGeneratorContractModel.GenerateCode() in D:\Work\GitHub\atc-rest-api-generator\src\Atc.Rest.ApiGenerator\SyntaxGenerators\Api\SyntaxGeneratorContractModel.cs:line 138
   at Atc.Rest.ApiGenerator.SyntaxGenerators.Api.SyntaxGeneratorContractModels.GenerateSyntaxTrees() in D:\Work\GitHub\atc-rest-api-generator\src\Atc.Rest.ApiGenerator\SyntaxGenerators\Api\SyntaxGeneratorContractModels.cs:line 69
   at Atc.Rest.ApiGenerator.Generators.ServerApiGenerator.GenerateContracts(List`1 operationSchemaMappings) in D:\Work\GitHub\atc-rest-api-generator\src\Atc.Rest.ApiGenerator\Generators\ServerApiGenerator.cs:line 236
   at Atc.Rest.ApiGenerator.Generators.ServerApiGenerator.Generate() in D:\Work\GitHub\atc-rest-api-generator\src\Atc.Rest.ApiGenerator\Generators\ServerApiGenerator.cs:line 51
   at Atc.Rest.ApiGenerator.Helpers.GenerateHelper.GenerateServerApi(String projectPrefixName, DirectoryInfo outputPath, DirectoryInfo outputTestPath, Tuple`3 apiDocument, ApiOptions apiOptions) in D:\Work\GitHub\atc-rest-api-generator\src\Atc.Rest.ApiGenerator\Helpers\GenerateHelper.cs:line 79
   at Atc.Rest.ApiGenerator.CLI.Commands.GenerateServerApiCommand.OnExecute(CommandLineApplication configCmd) in D:\Work\GitHub\atc-rest-api-generator\src\Atc.Rest.ApiGenerator.CLI\Commands\GenerateServerApiCommand.cs:line 42

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant