Skip to content
This repository has been archived by the owner on Apr 30, 2021. It is now read-only.

Can't export to new RAML/YAML files #22

Open
ex-nerd opened this issue Jul 14, 2015 · 4 comments
Open

Can't export to new RAML/YAML files #22

ex-nerd opened this issue Jul 14, 2015 · 4 comments

Comments

@ex-nerd
Copy link

ex-nerd commented Jul 14, 2015

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.

@an2deg
Copy link
Owner

an2deg commented Jul 14, 2015

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
#22.

Andrew Degtyarev
DA-RIPE

@solarkennedy
Copy link

@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?

@ex-nerd
Copy link
Author

ex-nerd commented Feb 20, 2016

@solarkennedy sorry, my company's doc generation standardized on Swagger so all of my RAML work got put on pause.

@solarkennedy
Copy link

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.

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

No branches or pull requests

3 participants