{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/cnpj-ai/json-schema/cnpj-ai-resposta-cnpj-schema.json",
  "title": "RespostaCNPJ",
  "x-generated": "2026-11-04",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/cnpj-ai-v1-openapi.yml#/components/schemas/RespostaCNPJ",
  "properties": {
    "dados": {
      "$ref": "#/$defs/DadosEmpresa"
    },
    "meta": {
      "$ref": "#/$defs/Metadados"
    }
  },
  "type": "object",
  "required": [
    "dados",
    "meta"
  ],
  "$defs": {
    "Codigo": {
      "properties": {
        "codigo": {
          "type": "string",
          "title": "Codigo"
        },
        "descricao": {
          "type": "string",
          "title": "Descricao"
        }
      },
      "type": "object",
      "required": [
        "codigo",
        "descricao"
      ],
      "title": "Codigo"
    },
    "Contato": {
      "properties": {
        "telefone1": {
          "type": "string",
          "title": "Telefone1"
        },
        "telefone2": {
          "type": "string",
          "title": "Telefone2"
        },
        "email": {
          "type": "string",
          "title": "Email"
        }
      },
      "type": "object",
      "required": [
        "telefone1",
        "telefone2",
        "email"
      ],
      "title": "Contato"
    },
    "DadosEmpresa": {
      "properties": {
        "cnpj_basico": {
          "type": "string",
          "title": "Cnpj Basico"
        },
        "empresa": {
          "anyOf": [
            {
              "$ref": "#/$defs/Empresa"
            },
            {
              "type": "null"
            }
          ]
        },
        "estabelecimentos": {
          "items": {
            "$ref": "#/$defs/Estabelecimento"
          },
          "type": "array",
          "title": "Estabelecimentos"
        },
        "socios": {
          "items": {
            "$ref": "#/$defs/Socio"
          },
          "type": "array",
          "title": "Socios"
        },
        "simples": {
          "anyOf": [
            {
              "$ref": "#/$defs/Simples"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "type": "object",
      "required": [
        "cnpj_basico",
        "empresa",
        "estabelecimentos",
        "socios",
        "simples"
      ],
      "title": "DadosEmpresa"
    },
    "Empresa": {
      "properties": {
        "razao_social": {
          "type": "string",
          "title": "Razao Social"
        },
        "natureza_juridica": {
          "$ref": "#/$defs/Codigo"
        },
        "qualificacao_responsavel": {
          "$ref": "#/$defs/Codigo"
        },
        "capital_social": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Capital Social"
        },
        "porte": {
          "$ref": "#/$defs/Codigo"
        },
        "ente_federativo_responsavel": {
          "type": "string",
          "title": "Ente Federativo Responsavel"
        }
      },
      "type": "object",
      "required": [
        "razao_social",
        "natureza_juridica",
        "qualificacao_responsavel",
        "capital_social",
        "porte",
        "ente_federativo_responsavel"
      ],
      "title": "Empresa"
    },
    "Endereco": {
      "properties": {
        "tipo_logradouro": {
          "type": "string",
          "title": "Tipo Logradouro"
        },
        "logradouro": {
          "type": "string",
          "title": "Logradouro"
        },
        "numero": {
          "type": "string",
          "title": "Numero"
        },
        "complemento": {
          "type": "string",
          "title": "Complemento"
        },
        "bairro": {
          "type": "string",
          "title": "Bairro"
        },
        "cep": {
          "type": "string",
          "title": "Cep"
        },
        "uf": {
          "type": "string",
          "title": "Uf"
        },
        "municipio": {
          "type": "string",
          "title": "Municipio"
        }
      },
      "type": "object",
      "required": [
        "tipo_logradouro",
        "logradouro",
        "numero",
        "complemento",
        "bairro",
        "cep",
        "uf",
        "municipio"
      ],
      "title": "Endereco"
    },
    "Estabelecimento": {
      "properties": {
        "cnpj": {
          "type": "string",
          "title": "Cnpj"
        },
        "cnpj_ordem": {
          "type": "string",
          "title": "Cnpj Ordem"
        },
        "matriz_filial": {
          "type": "string",
          "title": "Matriz Filial"
        },
        "nome_fantasia": {
          "type": "string",
          "title": "Nome Fantasia"
        },
        "situacao_cadastral": {
          "$ref": "#/$defs/Codigo"
        },
        "data_situacao_cadastral": {
          "anyOf": [
            {
              "type": "string",
              "format": "date"
            },
            {
              "type": "null"
            }
          ],
          "title": "Data Situacao Cadastral"
        },
        "motivo_situacao_cadastral": {
          "$ref": "#/$defs/Codigo"
        },
        "data_inicio_atividade": {
          "anyOf": [
            {
              "type": "string",
              "format": "date"
            },
            {
              "type": "null"
            }
          ],
          "title": "Data Inicio Atividade"
        },
        "cnae_principal": {
          "$ref": "#/$defs/Codigo"
        },
        "cnae_secundaria": {
          "items": {
            "$ref": "#/$defs/Codigo"
          },
          "type": "array",
          "title": "Cnae Secundaria"
        },
        "endereco": {
          "$ref": "#/$defs/Endereco"
        },
        "contato": {
          "$ref": "#/$defs/Contato"
        }
      },
      "type": "object",
      "required": [
        "cnpj",
        "cnpj_ordem",
        "matriz_filial",
        "nome_fantasia",
        "situacao_cadastral",
        "data_situacao_cadastral",
        "motivo_situacao_cadastral",
        "data_inicio_atividade",
        "cnae_principal",
        "cnae_secundaria",
        "endereco",
        "contato"
      ],
      "title": "Estabelecimento"
    },
    "Metadados": {
      "properties": {
        "versao": {
          "type": "string",
          "title": "Versao",
          "default": "v1"
        },
        "competencia": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Competencia"
        },
        "requisicao_id": {
          "type": "string",
          "format": "uuid",
          "title": "Requisicao Id"
        }
      },
      "type": "object",
      "required": [
        "competencia",
        "requisicao_id"
      ],
      "title": "Metadados"
    },
    "Representante": {
      "properties": {
        "nome": {
          "type": "string",
          "title": "Nome"
        },
        "qualificacao": {
          "$ref": "#/$defs/Codigo"
        }
      },
      "type": "object",
      "required": [
        "nome",
        "qualificacao"
      ],
      "title": "Representante"
    },
    "Simples": {
      "properties": {
        "opcao_simples": {
          "type": "boolean",
          "title": "Opcao Simples"
        },
        "data_opcao_simples": {
          "anyOf": [
            {
              "type": "string",
              "format": "date"
            },
            {
              "type": "null"
            }
          ],
          "title": "Data Opcao Simples"
        },
        "data_exclusao_simples": {
          "anyOf": [
            {
              "type": "string",
              "format": "date"
            },
            {
              "type": "null"
            }
          ],
          "title": "Data Exclusao Simples"
        },
        "opcao_mei": {
          "type": "boolean",
          "title": "Opcao Mei"
        },
        "data_opcao_mei": {
          "anyOf": [
            {
              "type": "string",
              "format": "date"
            },
            {
              "type": "null"
            }
          ],
          "title": "Data Opcao Mei"
        },
        "data_exclusao_mei": {
          "anyOf": [
            {
              "type": "string",
              "format": "date"
            },
            {
              "type": "null"
            }
          ],
          "title": "Data Exclusao Mei"
        }
      },
      "type": "object",
      "required": [
        "opcao_simples",
        "data_opcao_simples",
        "data_exclusao_simples",
        "opcao_mei",
        "data_opcao_mei",
        "data_exclusao_mei"
      ],
      "title": "Simples"
    },
    "Socio": {
      "properties": {
        "nome": {
          "type": "string",
          "title": "Nome"
        },
        "cpf_cnpj": {
          "type": "string",
          "title": "Cpf Cnpj"
        },
        "tipo": {
          "type": "string",
          "title": "Tipo"
        },
        "qualificacao": {
          "$ref": "#/$defs/Codigo"
        },
        "data_entrada": {
          "anyOf": [
            {
              "type": "string",
              "format": "date"
            },
            {
              "type": "null"
            }
          ],
          "title": "Data Entrada"
        },
        "faixa_etaria": {
          "type": "string",
          "title": "Faixa Etaria"
        },
        "representante_legal": {
          "anyOf": [
            {
              "$ref": "#/$defs/Representante"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "type": "object",
      "required": [
        "nome",
        "cpf_cnpj",
        "tipo",
        "qualificacao",
        "data_entrada",
        "faixa_etaria",
        "representante_legal"
      ],
      "title": "Socio"
    }
  }
}