RicoSuter / NJsonSchema

JSON Schema reader, generator and validator for .NET
http://NJsonSchema.org
MIT License
1.38k stars 532 forks source link

Generate TypeScript annotations based on minLength, format, pattern, etc. #1221

Open dmandreev opened 5 years ago

dmandreev commented 5 years ago

I have generated swagger.json with minLength, format, pattern attributes picked from System.ComponentModel.DataAnnotations ``

    "Name": {
      "title": "Your name:",
      "type": "string",
      "description": "Name.",
      "maxLength": 30,
      "minLength": 3
    },
    "Email": {
      "title": "Your email address *:",
      "type": "string",
      "description": "Email.",
      "minLength": 1,
      "pattern": "^([0-9a-zA-Z]([-.\\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\\w]*[0-9a-zA-Z]\\.)+[a-zA-Z]{2,9})$"
    },
    "PhoneNumber": {
      "title": "Your phone number:",
      "type": "string",
      "description": "Phone number.",
      "format": "phone",
      "pattern": "[0-9\\+]{1,}[0-9\\-]{3,15}$"
    },

`` Generated typescript have no such information. Does it correct/not implemented, will work in future?

RicoSuter commented 5 years ago

Not implemented yet

OlegUfaev commented 4 years ago

@RicoSuter Is there any plan to implement DataAnnotations support for TypeScript client? I think it would be convenient to be able to use this metadata in the TypeScript client.

RicoSuter commented 4 years ago

Is there any plan to implement DataAnnotations support for TypeScript client

This is not on my list as I personally or any of my clients do not need this ATM.

Moved to NJsonSchema as DTO class generation is handled here.

swadertater commented 1 year ago

Have you put it on your list yet?