RicoSuter/NJsonSchema

When using #ref the CSharp CodeGen does not include appropriate data annotiations

開放

#957 建立於 2019年4月23日

 (0 則留言) (0 個反應) (0 位負責人)C# (550 個分叉)github user discovery
help wantedtype: enhancement

倉庫指標

星標
 (1,581 顆星)
PR 合併指標
 (平均合併 39天 6小時) (30 天內合併 1 個 PR)

描述

I recently added some $refs to my schema and noticed that the generator dropped some of the annotation. Previous schema:

{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "type": "object",
    "additionalProperties": false,
    "properties": {
        "id": {
           "type": "string",
           "pattern": "^[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}$"
        }
    }
}

New schema:

{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "type": "object",
    "additionalProperties": false,
    "properties": {
        "id": {
           "$ref": "#/definitions/guid"
        }
    },
    "definitions": {
        "guid": {
            "type": "string",
            "pattern": "^[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}$"
        }
    }
}

The generated code no longer has the DataAnnotiation for regular expressions. It also removes length restrictions, etc.

貢獻者指南