Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$ref across multiple files #10

Closed
dmiorandi opened this issue Feb 27, 2016 · 3 comments
Closed

$ref across multiple files #10

dmiorandi opened this issue Feb 27, 2016 · 3 comments

Comments

@dmiorandi
Copy link
Contributor

I've got a couple of files. Each file is a schema, but there are references to schema in another files.
I expect that if all files are on input togheter than generator can resolve cross references, but it seem doesn't work. It doesn't care about files/dependency order.
Is it supported? If not any idea to achieve this?.

These are two example files:

{
     "id" :"ApiBaseObject",
     "$schema": "http://json-schema.org/draft-03/schema",
     "type": "object",
     "description": "ApiBaseObject of a record",
     "properties":   {
        "first" : {"type" : "string"}
      }
}
{
     "id" :"ApiMetadata",
     "$schema": "http://json-schema.org/draft-03/schema",
     "type": "object",
     "description": "Metadata of a record",
     "properties":   {
        "serverOperation" : {
            "type" : "string",
            "enum" : ["I","U","D"],
            "javaEnumNames" : ["INSERT","UPDATE","DELETE"]
        },
        "test" : {"$ref" : "ApiBaseObject" }
      }
}
@horiuchi
Copy link
Owner

The $ref target is followed the format: [target id]#[reference path]. And target id expect URL format.

I try to convert bellow case. That's success to convert.

{
    "id": "/ApiBaseObject",
    "$schema": "http://json-schema.org/draft-03/schema",
    "type": "object",
    "description": "ApiBaseObject of a record",
    "properties":   {
        "first" : { "type": "string"}
    }
}
{
    "id": "/ApiMetadata",
    "$schema": "http://json-schema.org/draft-03/schema",
    "type": "object",
    "description": "Metadata of a record",
    "properties":   {
        "serverOperation" : {
            "type" : "string",
            "enum" : ["I","U","D"],
            "javaEnumNames" : ["INSERT","UPDATE","DELETE"]
        },
        "test" : {"$ref" : "/ApiBaseObject#" }
    }
}

@dmiorandi
Copy link
Contributor Author

It works!. Tks to your suggestion. I've generated an over 100 interfaces d.ts file with no issues.
Using you project now I'm able to generate d.ts files from a raml / jsonschema definition.
That's Great! Tks @horiuchi

@horiuchi
Copy link
Owner

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants