Skip to content

Output a file per object (Swift) #687

Description

@rjstelling

Is it possible to out put a file per object when generating Swift?

I have JSON Schema files that refer to each other, but the referenced schema is creating in the same file, thus causing duplicate symbols when compiled.

The User.swift file generated has a User and Address struct in it, I'd like them to be separate files.

E.g

User Schema: User.schema

{
    "$ref": "#/definitions/User",
    "$schema": "http://json-schema.org/draft-06/schema#",
    "definitions": {
        "User": {
            "additionalProperties": false,
            "properties": {
                "basket_value": {
                    "type": "integer"
                },
                "default_address": {
                    "$ref": "./Address.schema"
                },
                "first_name": {
                    "type": "string"
                },
                "last_name": {
                    "type": "string"
                },
                "user_id": {
                    "type": "integer"
                }
            },
            "required": [
                "default_address",
                "first_name",
                "last_name",
                "user_id"
            ],
            "title": "user",
            "type": "object"
        }
    }
}

Address Schema: Address.schema

{
    "$ref": "#/definitions/Address",
    "$schema": "http://json-schema.org/draft-06/schema#",
    "definitions": {
        "Address": {
            "additionalProperties": false,
            "properties": {
                "address_id": {
                    "type": "integer"
                },
                "city": {
                    "type": "string"
                },
                "postcode": {
                    "type": "string"
                }
            },
            "required": [
                "address_id",
                "city",
                "postcode"
            ],
            "title": "address",
            "type": "object"
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions