Skip to content

Using Json Schema $ref #118

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

Closed
dlodeprojuicer opened this issue Oct 13, 2014 · 11 comments
Closed

Using Json Schema $ref #118

dlodeprojuicer opened this issue Oct 13, 2014 · 11 comments

Comments

@dlodeprojuicer
Copy link
Contributor

How can I use schema definition and $ref within the form?

I have this definition:

"definitions": { "CAN_postalCode": { "type":"string", "title": "Postal Code", "pattern":"^[A-Z][0-9][A-Z]( )?[0-9][A-Z][0-9]$" } }

In schema properties: Referring to the definition about

"province":{"$ref":"#/definitions/CAN_province"}

Demo link: http://igtestvm1.cloudapp.net:8989/offline/angularschemaform/views/refTest.html

def

@davidlgj
Copy link
Contributor

It's not supperted right now, but it's on the TODO list. See #69

The plan is to start off by pre processesing the schema, essentially putting a real reference to the subschema instead of the $ref where its needed building a new schema without $refs that schema form and tv4 can happily use..

Non-local $refs would need to be fetched or supplied with the the main schema, not sure how to solve them.

@mohsen1
Copy link

mohsen1 commented Nov 3, 2014

Resolving $ref has a lot of complexity. You can use this to resolve $refs in the schema
https://github.com/whitlockjc/json-refs

@ippeiukai
Copy link

FYI, following workaround did the job. Thanks for the hint!

JsonRefs.resolveRefs($scope.schema, function(err, resolvedSchema) {
  if(err) throw err;
  $scope.schema = resolvedSchema;
});

@davidlgj
Copy link
Contributor

davidlgj commented Jan 7, 2015

Nice! I feel like resolving the refs outside of schema form is more flexible than within. Closing this issue. Complain and I will reopen it. :-)

@AndreNel7
Copy link

newer workaround example

P.S. thanks ippeiukai for showing your workaround... which helped me upgrade it to this one :)

@marcelchastain
Copy link

@davidlgj any chance we can have this added to the documentation, prominently?

$refs are a fairly integral part of json schema definitions, and the only mention of the currently-supported-status is buried deep in github issues like this one.

@Anthropic
Copy link
Member

@marcelchastain it will be a part of the 1.0.0 release and is already in the current alpha. I've just added it to the alpha docs and will push them in the next update.

@legend80s
Copy link

@Anthropic Can we see the the alpha docs for ref now?

@Anthropic
Copy link
Member

@legend80s it's in the docs for the dev branch. Not much to say though, it just parses using fairly default options. More advanced options may come in future but not for a while.

@legend80s
Copy link

@Anthropic Can I see a demo of how to use $ref. The docs is too brief for a newbie

@Anthropic
Copy link
Member

JSON Schema website has examples of how to use $ref. $ref is only for the schema and not the UI schema, at least at this stage.

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

No branches or pull requests

8 participants