Closed rckrsc closed 7 years ago
Can you please describe the issue you have with more details? Also, your raml is not valid - you defined rules schema twice.
Oh I see. :D but this s not my bug can remove it first local and send some feedback to the developers of the API.
I'm not so sure about the issues. There were these parts of Code producing the error:
"items": { "$ref": "keyVal" }
Can you please provide smaller raml file that reproduces the issue? What is the actual error you are getting?
Hey, I will try to provide a smaller file.
The actual error is: IllegalArgumentException: URI is not absolute. It is failing at the provided sample location above.
Edit: Here you can find a smaller sample with the same error!
Workaround: replace $ref with !include
Hi @stojsavljevic , I have a look at this issue. First, I don't think it's a RAML 1.0 feature. From the RAML 1.0 sepcification, we can see that "schemas" and "schema" are deprecated and might be removed in a future RAML version.
Second, I don't think it's a bug of springmvc-raml-parser, but an error in raml file. From the JSON Schema specification, we can refer a schema snippet of current document as following: { "$ref": "#/definitions/address" } we can refer a a schema snippet of another document by relative URL as following: { "$ref": "definitions.json#/address" } You can refer to the detail from [https://spacetelescope.github.io/understanding-json-schema/structuring.html].
But here from the raml file, we can see ` schemas:
Though here JSON schemas are defined in a raml file, but they are separated each other. ie. ` schemas:
How do you think about it?
BR, Xiangbin
Hi @champagne
I agree that it's not a 'real' 1.0
feature although still supported in the spec.
In general, I don't think we (in this project) should support schemas in 1.0
code flow.
But for 0.8
this looks like a missing feature.
Using include is just a workaround. JSON schemas can reference each other using ref: http://json-schema.org/latest/json-schema-core.html#rfc.section.8
So, in the above example, if addressbook
is already defined, testinput1
should be able to reference it using $ref.
Hi @stojsavljevic , Thanks for your reply.
Yes, for RAML 0.8, we should support JSON Schema. But it not an issue of raml-parser, but an issue of json shema parser. I have found that jsonschema2pojo has support $ref already. Please see https://github.com/joelittlejohn/jsonschema2pojo/wiki/Reference#ref.
For this issue, though addressbook and testinput1 are defined in a same raml file, but they are treated as two independent json schema file, but user try to refer an external json schema snippet by the way of refering to a internal json schema snippet. So I still believe this is a valid RAML file but with invalid JSON Schema. It's not a raml-parser bug. The following links are helpful to understand how to using JSON Schema $ref:
BR, Xiangbin
It looks you're right @champagne
If somebody feels we're missing something - please reopen this one.
Just one more hint: you can try to use classpath:
when defining $ref
.
Something like this:
...
"payloadItems" : {
"$schema": "http://json-schema.org/draft-04/schema",
"type": "array",
"items" : {
"$ref" : "classpath:payloadItem.schema"
}
}
...
This is the raml file i would like use for client generation but there is an exception during the code generation.
https://devportal.yaas.io/services/beta/loyaltyrule/v1/api.raml