- 
                Notifications
    
You must be signed in to change notification settings  - Fork 285
 
OpenAPI - Improved resolving of database types to json data types #1568
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
OpenAPI - Improved resolving of database types to json data types #1568
Conversation
… converter used in OpenAPI doc creation.
… db type mapping to CLR(system) and JsonDataType/DbType. And added tests.
…tion in another pr.
        
          
                src/Service.Tests/OpenApiDocumentor/CLRtoJsonValueTypeUnitTests.cs
              
                Outdated
          
            Show resolved
            Hide resolved
        
              
          
                src/Service.Tests/OpenApiDocumentor/CLRtoJsonValueTypeUnitTests.cs
              
                Outdated
          
            Show resolved
            Hide resolved
        
      | 
           Could you attach a screenshot of how the entity (which is attached in the issue) looks like now in swagger UI?  | 
    
….tryparse override used since latest syntax eliminates requirement to do null check and casting. Removed "DateTime" and "Time" from TypeHelper._systemTypeToDbTypeMap because they caused GraphQL type tests to fail because of exceptions converting from DateTimeOffset to DateTime. That issue may be fixed by #1473
          
 Added before and after to the PR description  | 
    
…value types to their underlying types, also adds comments to explain in tests and in engine code (TypeHelper)
…ght diffs that this PR actually contributes, as it doesn't change the whole file as github currently suggests. Updates TypeHelper dictionary to be defined by providing an enumerable of key/value pairs instead of indexer assignment.
…s://github.com/Azure/data-api-builder into dev/seantleonard/openapi_systemtojsondatatypes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, Thanks for refactoring our type system!
        
          
                src/Service.Tests/OpenApiDocumentor/CLRtoJsonValueTypeUnitTests.cs
              
                Outdated
          
            Show resolved
            Hide resolved
        
      | 
           Does   | 
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a question for DateTimeOffset to DbType mapping.
          
 My bad, that was actually a default value (thanks for catching). A default value resolved by swagger UI based on the json data type. I added extra example of the raw openapi schema doc which shows the actual json data type resolved as a result of this change. (this requires extra click throughs in swagger to 'view schema').  | 
    
…mTypeToDbTypeMap to avoid any possible regression.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks again for refactoring our Type system!
…er unexpected sqldbtyp. Also updated configurationtests to not have single line namespace to accurately show changes.
Why make this change?
What is this change?
improves the mapping between SqlDbType <=> CLR/.NET Framwork (System) types <=> JsonDataType so that OpenApi document generation resolves the appropriate value types in REST endpoint result field value types and input (request body) field value types.
To view OpenApi document output, browse to the endpoint /swagger
Before (Swagger view with default values based on resolved JSON data type)
{ "value": [ { "typeid": 0, "byte_types": "string", "short_types": 0, "int_types": 0, "long_types": 0, "string_types": "string", "single_types": 0, "float_types": 0, "decimal_types": 0, "boolean_types": true, "date_types": "Unknown Type: undefined", "datetime_types": "Unknown Type: undefined", "datetime2_types": "Unknown Type: undefined", "datetimeoffset_types": "Unknown Type: undefined", "smalldatetime_types": "Unknown Type: undefined", "bytearray_types": "string", "guid_types": "string" } ] }After (Swagger view with default values based on resolved JSON data type)
{ "value": [ { "typeid": 0, "byte_types": "string", "short_types": 0, "int_types": 0, "long_types": 0, "string_types": "string", "single_types": 0, "float_types": 0, "decimal_types": 0, "boolean_types": true, "date_types": "string", "datetime_types": "string", "datetime2_types": "string", "datetimeoffset_types": "string", "smalldatetime_types": "string", "bytearray_types": "string", "guid_types": "string" } ] }After: OpenApi document json
How was this tested?