jdiegodcp / ramlfications

Python parser for RAML
https://ramlfications.readthedocs.org
Apache License 2.0
234 stars 49 forks source link

Top-level schemas are not resolved when assigned to resources #14

Open econchick opened 9 years ago

econchick commented 9 years ago

For example:

#%RAML 0.8
title: Example Web API
version: v1
schemas:
  - Thingy: !include includes/post-thingy-schema.json
# <---snip--->
      responses:
        200:
          body:
            application/json:
              schema: Thingy

The last line, when parsed, isn't actually resolved to the defined schema:

>>> resp = endpoint.responses[0]
>>> resp.body[0].schema
'Thingy'

It should behave like endpoint.resource_type were you can actually access the schema.

vlcinsky commented 9 years ago

I hit the same problem, instead of getting the schema I got name of it.

I was thinking, if that was by design or not. The documentation: https://ramlfications.readthedocs.org/en/latest/api.html#ramlfications.ramlfications.parameters.Body does not expect a name of the schema to be expected result.

To me it really seems more practical to get the schema resolved (as described in the original PR).

Workaround: I had to convert schemas in bodies from named ones into directly included ones. But I was lucky person as I was allowed to modify the RAML file.

econchick commented 9 years ago

Thanks @vlcinsky - I am working on a couple of patches related to this and #23 - good to know there are some users of the library that want this functionality :D I agree that resolving the schema is ideal.

vlcinsky commented 9 years ago

@econchick Sounds very promising. I am really found of RAML (after longer fight with Swagger I have to appreciate, RAML serves much better my testing needs and has much better core concepts). Coding most of my stuff in Python I found ramlfications of great value. Thanks you for that.

rebeling commented 8 years ago

What is the status of this issue? It is already deprecated in RAML 1.0 to name it schemas and use types instead. But the issue will be the same: a name instead of an schema object.

Do you use definitions to validate an input or output? And how do you do it? I am using jsonschema for now, but I thought it would be nice feature of ramlfication to validate object against defined schema.

econchick commented 8 years ago

@rebeling can you link me to where RAML 1.0 explicitly says schemas are deprecated? I may have just missed it.

My intention with schemas (related: #15) is to indeed have ramlfications validate against the defined schema. Same with the newly added Data Types.

I'm putting a lot of work on this library this weekend (see roadmap), hopefully I can address this too.

rebeling commented 8 years ago

15 ok, missed this one - yeah, jsonschema ;)

For deprecation for schemas find the terms at http://blog.raml.org/. I am ramlficated already from your project, thanks and stay tuned.

pokidovea commented 8 years ago

What is the status of this issue?

econchick commented 8 years ago

@pokidovea hmm yeah - 0.2.0 development is a bit slow. How much of a blocker is this particular issue for you?

pokidovea commented 8 years ago

Unfortunately, it prevents me from using this lib. I have to use JS analogue.

econchick commented 8 years ago

@pokidovea ah well, we don't want that! 😄 I'll try to get some time this week/weekend to address this.