Forum Discussion

ovirta's avatar
ovirta
Occasional Visitor
5 years ago

Generate javascript client validation from swagger.json

Is it possible to generate client side validation rules from swagger.json, which has validation parameters in definitions section?

 

Our Swagger.json has following section:

 

    "definitions": {
        "API.Controllers.AccountsController": {
            "description": "Company information",
            "required": [
                "name"
            ],
            "type": "object",
            "properties": {
                "name": {
                    "description": "Name of company",
                    "maxLength": 100,
                    "minLength": 0,
                    "type": "string"
                },

but the maxLength and minLength are ignored when creating the client files with http://editor.swagger.io/#

 

Same goes for Swaggers own Petstore server sample.

 

                    {
                        "name": "orderId",
                        "in": "path",
                        "description": "ID of pet that needs to be fetched",
                        "required": true,
                        "type": "integer",
                        "maximum": 10,
                        "minimum": 1,
                        "format": "int64"
                    }

Maximum and minimum are not processed.

 

Any help on creating client side validations from server configurations is very much appreciated.

Thanks for great tooling!

 

No RepliesBe the first to reply