corvus-dotnet / Corvus.JsonSchema

Support for Json Schema validation and entity generation
Apache License 2.0
99 stars 9 forks source link

Added the ability to define an explicit type with `$corvusTypeName`. #366

Closed mwadams closed 4 months ago

mwadams commented 4 months ago

If you add a $corvusTypeName keyword to a schema and give it a string value, it will be used as the basis for the type name of the schema, overriding the default naming convention.

If the value is present, and is a string of Length >= 1, it will converted into a PascalCased basis for the type name.

Naming collisions will still be resolved in the usual way.

For example:

File: test.json

{
    "type": "array",
    "prefixItems": [
        {
            "$corvusTypeName": "PositiveInt32",
            "type": "integer",
            "format": "int32",
            "minimum": 1
        },
        { "type": "string" },
        {
            "type": "string",
            "format": "date-time"
        }
    ],
    "unevaluatedItems": false
}
generatejsonschematypes --rootNamespace JsonSchemaSample.Api --outputPath Model test.json
Generating: PositiveInt32
Generating: Test
github-actions[bot] commented 4 months ago

Code Coverage Summary Report - Linux (net8.0)

Code Coverage

Package Line Rate Branch Rate Complexity Health
Corvus.Json.JsonSchema.Draft7 14% 14% 8051
Corvus.Json.CodeGeneration.201909 31% 18% 27044
Corvus.Json.Patch 25% 21% 4237
Corvus.Json.JsonSchema.Draft6 14% 14% 7329
Corvus.Json.JsonSchema.Draft202012 15% 14% 11933
Corvus.Json.CodeGeneration.202012 31% 18% 27351
Corvus.Json.CodeGeneration.6 32% 18% 21372
Corvus.Json.CodeGeneration.Abstractions 86% 75% 1299
Corvus.Json.JsonSchema.Draft201909 14% 14% 12408
Corvus.Json.CodeGeneration.7 31% 18% 23584
Corvus.Json.ExtendedTypes 39% 33% 17107
Corvus.Json.Specs 98% 79% 4618
Summary 35% (75475 / 216080) 20% (26655 / 135779) 166333
github-actions[bot] commented 4 months ago

Test Results

     1 files       1 suites   16m 57s :stopwatch: 11 211 tests 11 211 :white_check_mark: 0 :zzz: 0 :x: 12 259 runs  12 259 :white_check_mark: 0 :zzz: 0 :x:

Results for commit c1ff0ccb.

:recycle: This comment has been updated with latest results.

github-actions[bot] commented 4 months ago

Code Coverage Summary Report - Windows (net481)

Code Coverage

Package Line Rate Branch Rate Complexity Health
Corvus.Json.Patch 27% 23% 3945
Corvus.Json.JsonSchema.Draft7 15% 15% 7543
Corvus.Json.JsonSchema.Draft6 15% 15% 6862
Corvus.Json.JsonSchema.Draft201909 15% 15% 11715
Corvus.Json.CodeGeneration.6 32% 18% 21374
Corvus.Json.CodeGeneration.7 31% 18% 23586
Corvus.Json.CodeGeneration.201909 31% 18% 27047
Corvus.Json.CodeGeneration.202012 31% 18% 27354
Corvus.Json.JsonSchema.Draft202012 16% 16% 11277
Corvus.Json.ExtendedTypes 39% 36% 11333
Corvus.Json.CodeGeneration.Abstractions 87% 75% 1291
Corvus.Json.Specs 98% 81% 4344
Summary 35% (72343 / 206356) 20% (25091 / 127759) 157671
github-actions[bot] commented 4 months ago

Code Coverage Summary Report - Windows (net8.0)

Code Coverage

Package Line Rate Branch Rate Complexity Health
Corvus.Json.Patch 25% 21% 4237
Corvus.Json.JsonSchema.Draft7 14% 14% 8051
Corvus.Json.JsonSchema.Draft6 14% 14% 7329
Corvus.Json.JsonSchema.Draft202012 15% 14% 11933
Corvus.Json.JsonSchema.Draft201909 14% 14% 12408
Corvus.Json.CodeGeneration.6 32% 18% 21372
Corvus.Json.CodeGeneration.7 31% 18% 23584
Corvus.Json.CodeGeneration.201909 31% 18% 27044
Corvus.Json.CodeGeneration.202012 31% 18% 27351
Corvus.Json.ExtendedTypes 39% 33% 17107
Corvus.Json.CodeGeneration.Abstractions 86% 75% 1299
Corvus.Json.Specs 98% 79% 4618
Summary 35% (75506 / 216080) 20% (26682 / 135779) 166333