jsonschema icon indicating copy to clipboard operation
jsonschema copied to clipboard

Store Id field

Open kellrott opened this issue 2 years ago • 3 comments
trafficstars

Make the id field from schema doc visible to user. This PD adds the Id field to schema struct and populates it using draft.getID method. Otherwise, the contents of the id field is not visible.

kellrott avatar Dec 23 '22 00:12 kellrott

  • rename Id to ID

You are saving id from schema document as it is. in schema id can be relative also. I am thinking it would be better to store absolute id in struct.

santhosh-tekuri avatar Dec 23 '22 06:12 santhosh-tekuri

Renaming Id to ID should be easy. Do you have any thoughts on the best way to resolve the global URL and append the id?

kellrott avatar Dec 27 '22 06:12 kellrott

currently id is computed and stored in resource.url see draft.go:80. but here also we don't store the anchor in resource.url. anchors are calculated on demand see Draft.anchors method

you can combine resource.url+'#'+anchor to compute id. it is little bit involved. I do not see anyone has an use case where they need ID. I don't find any compelling reason to add additional time to compilation just to compute this field

santhosh-tekuri avatar Dec 29 '22 07:12 santhosh-tekuri