OpenAPI - Improved resolving of database types to json data types#1568
OpenAPI - Improved resolving of database types to json data types#1568seantleonard merged 15 commits intomainfrom
Conversation
… converter used in OpenAPI doc creation.
… db type mapping to CLR(system) and JsonDataType/DbType. And added tests.
…tion in another pr.
|
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
Aniruddh25
left a comment
There was a problem hiding this comment.
LGTM, Thanks for refactoring our type system!
|
Does |
Aniruddh25
left a comment
There was a problem hiding this comment.
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.
…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?