Can't export to new RAML/YAML files
I tried to use this today to flatten out some RAML files (so I could import them into postman) and discovered that the pyraml models don't re-encode cleanly. Using a simple script like this one:
import pyraml.parser
import yaml
p = pyraml.parser.load('main.raml')
print yaml.dump(p)
... elements encode using a variety of non-generic types like:
-
!!python/object:pyraml.entities.RamlTrait -
!!python/object:pyraml.entities.RamlResource -
!!python/object:pyraml.entities.RamlMethod -
!!python/unicode(for embedded JSON schemas)
And so forth.
I haven't yet tested this but it looks like fixing some of these might be as easy as extending BaseModel from yaml.YAMLObject instead of plain object.
Is this something you'd be open to having fixed (even if it means creating a pyraml.parser.dump(p) type method)? If so, I can keep poking at it.
Hi Chris.
We can't easy extend BaseModel from YAMLObject. In this case I got TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases. This is because YAMLObject is also metaclass by itself. Extending Schema from yaml.YAMLObject fixed that but broke many tests. If you'll find working solution I would be very grateful.
Best regards,
On Tue, Jul 14, 2015 at 9:02 AM, Chris Petersen [email protected] wrote:
I tried to use this today to flatten out some RAML files (so I could import them into postman) and discovered that the pyraml models don't re-encode cleanly. Using a simple script like this one:
import pyraml.parserimport yaml p = pyraml.parser.load('main.raml')print yaml.dump(p)
... elements encode using a variety of non-generic types like:
- !!python/object:pyraml.entities.RamlTrait
- !!python/object:pyraml.entities.RamlResource
- !!python/object:pyraml.entities.RamlMethod
- !!python/unicode (for embedded JSON schemas)
And so forth.
I haven't yet tested this but it looks like fixing some of these might be as easy as extending BaseModel from yaml.YAMLObject instead of plain object.
Is this something you'd be open to having fixed (even if it means creating a pyraml.parser.dump(p) type method)? If so, I can keep poking at it.
— Reply to this email directly or view it on GitHub https://github.com/an2deg/pyraml-parser/issues/22.
Andrew Degtyarev DA-RIPE
@ex-nerd I'm also trying to flatten some RAML files like you and I found this issue. It has been a while, do you have any update on if you were able to achieve this, using this parser or anything else?
@solarkennedy sorry, my company's doc generation standardized on Swagger so all of my RAML work got put on pause.
Gotcha. This could be considered closed if the scope of this project is not intended to include raml dumping, only raml parsing.
For my particular needs I ended up using a node based API spec converter to go "from" RAML "to" RAML which created a consolidated file for me.