Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • castellum castellum
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 2
    • Issues 2
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 1
    • Merge requests 1
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • CastellumCastellum
  • castellumcastellum
  • Merge requests
  • !1521

Add script to export current attribute descriptions as JSONSchema

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Bengfort requested to merge attribute-schema into main Sep 07, 2020
  • Overview 0
  • Commits 1
  • Pipelines 1
  • Changes 1

This is a script that converts attribute descriptions to JSONSchema as used in Leipzig. It includes two different modes:

  • Default mode is compatible with the format used in huscy
  • Raw mode is compatible with the format used in castellum

There are two notable things missing from this representation:

  • Translations (for label, help text, and choices labels)
  • Filter-specific information such as operators or filter_form_class

I did not add support for Categories yet because they are rarely used.

$ ./manage.py attribute_schema
{
    "properties": {
        "Date of birth": {
            "format": "date",
            "type": "string"
        },
        "Handedness": {
            "enum": [
                "Right",
                "Left"
            ],
            "type": "string"
        },
        "Highest degree": {
            "enum": [
                "No degree",
                "Elementary school",
                "Hauptschule",
                "Mittlere Reife",
                "Abitur",
                "Bachelor",
                "Master"
            ],
            "type": "string"
        },
        "Language": {
            "type": "string"
        }
    },
    "type": "object"
}
$ ./manage.py attribute_schema --raw
{
    "properties": {
        "d5": {
            "description": "Handedness",
            "enum": [
                10,
                11
            ],
            "type": "integer"
        },
        "d6": {
            "description": "Language",
            "type": "string"
        },
        "d7": {
            "description": "Date of birth",
            "format": "date",
            "type": "string"
        },
        "d8": {
            "description": "Highest degree",
            "enum": [
                12,
                13,
                14,
                15,
                16,
                17,
                18
            ],
            "type": "integer"
        }
    },
    "type": "object"
}
Edited Sep 08, 2020 by Bengfort
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: attribute-schema