jdiegodcp / ramlfications

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

Resource Type inheritance of other resource types do not properly work #47

Closed econchick closed 8 years ago

econchick commented 8 years ago

When a resource type inherits from another resource type, the "child" resource type does not correctly overwrite the inherited properties.

Current behavior:

#%RAML 0.8

---
title: Example API
baseUri: http://example.com
version: v1
resourceTypes:
  - base:
      description: a base resource type for other resource types to inherit from
      get:
        description: This description should be overwritten
        queryParameters:
          inheritedParam:
            description: query parameter that should be inherited
  - inheritFromBase:
      description: this resource type inherits from `base`
      type: base
      get:
        description: overwrites base description
        queryParameters:
          aNewParam:
            description: another parameter added from base type
            example: a new param
/inherit-resource-type:
  type: inheritsBase
  description: resource type inherits resource type
  get:
    displayName: get resource type

When parsed:

>>> api = parse(RAML_FILE)
>>> res = api.resources[0]
>>> r
ResourceNode(method='get', path='/inherit-resource-type')
>>> r.description.raw   # this is expected
'overwrites base description'
>>> r.query_params  # this is not - does not inherit query params
 [QueryParameter(name='aNewParam')]

I would expect r.query_params to actually have two QueryParameter objects.

econchick commented 8 years ago

Potential fix with #73

econchick commented 8 years ago

Addressed completely (hopefully) with #76