RicoSuter/NJsonSchema

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

Open

#957 ouverte le 23 avr. 2019

Voir sur GitHub
 (0 commentaires) (0 réactions) (0 assignés)C# (550 forks)github user discovery
help wantedtype: enhancement

Métriques du dépôt

Stars
 (1 578 stars)
Métriques de merge PR
 (Aucune PR mergée en 30 j)

Description

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.

Guide contributeur