{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://enknapp.nu/api/consultant-public.schema.json",
  "title": "Consultant Public Profile",
  "description": "Public consultant profile returned by the Enknapp API",
  "type": "object",
  "required": ["id", "schema_version", "personal"],
  "properties": {
    "id": {
      "type": "string",
      "pattern": "^[a-z0-9-]+$",
      "description": "Unique consultant identifier"
    },
    "schema_version": {
      "type": "string",
      "const": "2.0",
      "description": "API schema version"
    },
    "lastModified": {
      "type": "string",
      "format": "date-time",
      "description": "ISO 8601 timestamp of last profile update"
    },
    "personal": {
      "type": "object",
      "required": ["name"],
      "properties": {
        "name": {
          "type": "string",
          "description": "Full name"
        },
        "headline": {
          "type": "string",
          "description": "Professional headline or tagline"
        },
        "location": {
          "type": "object",
          "properties": {
            "city": { "type": "string" },
            "region": { "type": "string" },
            "country": { "type": "string" },
            "country_code": {
              "type": "string",
              "pattern": "^[A-Z]{2}$",
              "description": "ISO 3166-1 alpha-2 country code"
            }
          }
        },
        "company": {
          "type": "object",
          "properties": {
            "name": { "type": "string", "description": "Trading name" },
            "legal_name": { "type": "string", "description": "Registered company name" }
          }
        },
        "contact": {
          "type": "object",
          "properties": {
            "email": { "type": "string", "format": "email" },
            "phone": { "type": "string" },
            "linkedin": { "type": "string" },
            "website": { "type": "string" }
          }
        }
      }
    },
    "engagement": {
      "type": "object",
      "properties": {
        "availability": {
          "type": "object",
          "properties": {
            "from_date": {
              "type": "string",
              "format": "date",
              "description": "Date available from (YYYY-MM-DD)"
            },
            "status": {
              "type": "string",
              "enum": ["available", "available_soon", "busy", "not_available"],
              "description": "Current availability status"
            },
            "note": {
              "type": "string",
              "description": "Additional availability information"
            }
          }
        },
        "arrangements": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": ["remote", "hybrid", "onsite"]
          },
          "description": "Accepted work arrangements"
        },
        "f_skatt": {
          "type": "boolean",
          "description": "Has F-skatt (Swedish tax registration for self-employed)"
        }
      }
    },
    "summary": {
      "type": "object",
      "properties": {
        "short": {
          "type": "string",
          "description": "Brief summary (1-2 sentences)"
        },
        "full": {
          "type": "string",
          "description": "Full professional summary"
        }
      }
    },
    "skills": {
      "type": "object",
      "properties": {
        "categories": {
          "type": "object",
          "additionalProperties": {
            "type": "array",
            "items": { "type": "string" }
          },
          "description": "Skills grouped by category"
        },
        "languages": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "description": "ISO 639-1 language code"
              },
              "name": {
                "type": "string",
                "description": "Language name"
              },
              "level": {
                "type": "string",
                "enum": ["native", "full_professional", "professional_working", "limited_working", "elementary"],
                "description": "Proficiency level"
              }
            }
          },
          "description": "Spoken languages with proficiency"
        }
      }
    },
    "certifications": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["name", "issuer"],
        "properties": {
          "id": { "type": "string" },
          "name": { "type": "string", "description": "Certification name" },
          "issuer": { "type": "string", "description": "Issuing organization" },
          "issued": { "type": "string", "description": "Issue date" },
          "expires": { "type": ["string", "null"], "description": "Expiration date" },
          "credential_id": { "type": ["string", "null"] },
          "active": { "type": "boolean", "description": "Currently valid" }
        }
      }
    },
    "employment": {
      "type": "array",
      "items": { "$ref": "#/$defs/workRecord" },
      "description": "Employment history"
    },
    "contracts": {
      "type": "array",
      "items": { "$ref": "#/$defs/contractRecord" },
      "description": "Contract/consulting engagements"
    },
    "education": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["institution"],
        "properties": {
          "id": { "type": "string" },
          "institution": { "type": "string" },
          "degree": { "type": "string" },
          "field": { "type": "string" },
          "start": { "type": "string" },
          "end": { "type": "string" },
          "description": { "type": "string" },
          "coursework": {
            "type": "array",
            "items": { "type": "string" }
          },
          "thesis": { "type": "string" }
        }
      }
    },
    "attributes": {
      "type": "object",
      "additionalProperties": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "trait": { "type": "string" },
            "evidence": { "type": "string" }
          }
        }
      },
      "description": "Professional attributes with evidence"
    },
    "_links": {
      "type": "object",
      "properties": {
        "self": { "type": "string", "description": "Link to this resource" },
        "photo": { "type": "string", "description": "Link to profile photo" }
      },
      "description": "HATEOAS links"
    }
  },
  "$defs": {
    "workRecord": {
      "type": "object",
      "required": ["company", "start"],
      "properties": {
        "id": { "type": "string" },
        "company": { "type": "string" },
        "roles": {
          "type": "array",
          "items": { "type": "string" }
        },
        "type": {
          "type": "string",
          "enum": ["employment", "self_employed", "contract"]
        },
        "start": { "type": "string" },
        "end": { "type": ["string", "null"] },
        "current": { "type": "boolean" },
        "location": { "type": "string" },
        "industries": {
          "type": "array",
          "items": { "type": "string" }
        },
        "description": { "type": "string" },
        "key_results": {
          "type": "array",
          "items": { "type": "string" }
        },
        "technologies": {
          "type": "array",
          "items": { "type": "string" }
        },
        "leadership": {
          "type": "array",
          "items": { "type": "string" }
        },
        "projects": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "name": { "type": "string" },
              "description": { "type": "string" }
            }
          }
        }
      }
    },
    "contractRecord": {
      "type": "object",
      "required": ["client", "start"],
      "properties": {
        "id": { "type": "string" },
        "client": { "type": "string" },
        "through": { "type": "string", "description": "Intermediary/agency" },
        "through_company": { "type": "string" },
        "roles": {
          "type": "array",
          "items": { "type": "string" }
        },
        "start": { "type": "string" },
        "end": { "type": ["string", "null"] },
        "current": { "type": "boolean" },
        "location": { "type": "string" },
        "industries": {
          "type": "array",
          "items": { "type": "string" }
        },
        "description": { "type": "string" },
        "key_results": {
          "type": "array",
          "items": { "type": "string" }
        },
        "deliverables": {
          "type": "array",
          "items": { "type": "string" }
        },
        "technologies": {
          "type": "array",
          "items": { "type": "string" }
        }
      }
    }
  }
}
