{
    "openapi": "3.1.0",
    "info": {
        "title": "Verificare CNP API",
        "version": "1.0.0",
        "description": "Public JSON API for Romanian CNP validation and generation."
    },
    "servers": [
        {
            "url": "https://verificarecnp.ro/api/v1"
        }
    ],
    "paths": {
        "/cnp/validate": {
            "post": {
                "summary": "Validate one or multiple CNP values",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/ValidationRequest"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ValidationResponse"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Malformed JSON request"
                    },
                    "415": {
                        "description": "Content-Type is not application/json"
                    },
                    "422": {
                        "description": "Request validation failed"
                    },
                    "429": {
                        "description": "Rate limit exceeded (60 requests/minute)"
                    }
                }
            }
        },
        "/cnp/generate": {
            "post": {
                "summary": "Generate valid CNP values",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/GeneratorRequest"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/GeneratorResponse"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Malformed JSON request"
                    },
                    "415": {
                        "description": "Content-Type is not application/json"
                    },
                    "422": {
                        "description": "Request validation failed"
                    },
                    "429": {
                        "description": "Rate limit exceeded (10 requests/minute)"
                    }
                }
            }
        },
        "/resources/generator": {
            "get": {
                "summary": "Get generator regions and options",
                "parameters": [
                    {
                        "name": "lang",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "ro",
                                "en"
                            ],
                            "default": "ro"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Generator resources",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "429": {
                        "description": "Rate limit exceeded (120 requests/minute)"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "ValidationRequest": {
                "type": "object",
                "required": [
                    "input"
                ],
                "properties": {
                    "input": {
                        "oneOf": [
                            {
                                "type": "string",
                                "examples": [
                                    "1960527400195"
                                ]
                            },
                            {
                                "type": "integer"
                            },
                            {
                                "type": "array",
                                "items": {
                                    "oneOf": [
                                        {
                                            "type": "string"
                                        },
                                        {
                                            "type": "integer"
                                        }
                                    ]
                                }
                            }
                        ]
                    },
                    "lang": {
                        "$ref": "#/components/schemas/Language"
                    }
                }
            },
            "GeneratorRequest": {
                "type": "object",
                "required": [
                    "limit"
                ],
                "properties": {
                    "limit": {
                        "type": "integer",
                        "minimum": 1
                    },
                    "s": {
                        "oneOf": [
                            {
                                "type": "string"
                            },
                            {
                                "type": "integer"
                            }
                        ],
                        "enum": [
                            "1",
                            "2",
                            "3",
                            "4",
                            "5",
                            "6",
                            "7",
                            "8",
                            "9"
                        ]
                    },
                    "birth_date": {
                        "type": "string",
                        "format": "date"
                    },
                    "county": {
                        "type": "string"
                    },
                    "serial": {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 999
                    },
                    "mode": {
                        "type": "string",
                        "enum": [
                            "sequential",
                            "random"
                        ]
                    },
                    "lang": {
                        "$ref": "#/components/schemas/Language"
                    }
                }
            },
            "Language": {
                "type": "string",
                "enum": [
                    "ro",
                    "en"
                ],
                "default": "ro"
            },
            "ValidationResponse": {
                "type": "object",
                "properties": {
                    "success": {
                        "type": "boolean"
                    },
                    "lang": {
                        "$ref": "#/components/schemas/Language"
                    },
                    "mode": {
                        "type": "string",
                        "enum": [
                            "single",
                            "bulk"
                        ]
                    }
                }
            },
            "GeneratorResponse": {
                "type": "object",
                "properties": {
                    "success": {
                        "type": "boolean"
                    },
                    "lang": {
                        "$ref": "#/components/schemas/Language"
                    },
                    "count": {
                        "type": "integer"
                    },
                    "items": {
                        "type": "array",
                        "items": {
                            "type": "object"
                        }
                    }
                }
            },
            "ErrorResponse": {
                "type": "object",
                "properties": {
                    "success": {
                        "type": "boolean",
                        "const": false
                    },
                    "error": {
                        "type": "object"
                    }
                }
            }
        }
    }
}