class RamlMethod(Model): notNull = Bool() description = String() body = Reference(RamlBody) responses = Map(Int(), Reference(RamlBody)) #responses = Map(Int(), Reference(RamlResponse)) queryParameters = Map(String(), Reference(RamlQueryParameter))
class RamlResource(Model): displayName = String() description = String() uri = String() type = Reference(RamlTrait, field_name="is") parentResource = Reference("pyraml.entities.RamlResource") methods = Map(String(), Reference(RamlBody)) resources = Map(String(), Reference("pyraml.entities.RamlResource"))
class RamlBody(Model): schema = String() example = String() notNull = Bool() formParameters = Map(String(), Reference(RamlHeader)) headers = Map(String(), Reference(RamlHeader)) body = Map(String(), Reference("pyraml.entities.RamlBody")) is_ = List(String(), field_name="is")
class RamlResource(ResourceTypedEntity, TraitedEntity, SecuredEntity, Model): """ http://raml.org/spec.html#resources-and-nested-resources """ displayName = String() description = String() parentResource = Reference("pyraml.entities.RamlResource") methods = Map(String(), Reference(RamlMethod)) resources = Map(String(), Reference("pyraml.entities.RamlResource")) uriParameters = RamlNamedParametersMap() baseUriParameters = RamlNamedParametersMap()
class RamlMethod(TraitedEntity, SecuredEntity, Model): """ http://raml.org/spec.html#methods """ notNull = Bool() description = String() body = Map(String(), Reference(RamlBody)) responses = Map(Int(), Reference(RamlResponse)) queryParameters = RamlNamedParametersMap() baseUriParameters = RamlNamedParametersMap() headers = RamlNamedParametersMap() protocols = List( Choice(field_name='protocols', choices=RAML_VALID_PROTOCOLS))
class RamlRoot(Model): raml_version = String(required=True) title = String() version = String() baseUri = String() protocols = List(String()) mediaType = String() documentation = List(Reference(RamlDocumentation)) traits = Map(String(), Reference(RamlTrait)) resources = Map(String(), Reference(RamlResource)) resourceTypes = Map(String(), Reference(RamlResourceType))
class RamlSecuritySchemeDescription(Model): """ The describedBy attribute MAY be used to apply a trait-like structure to a security scheme mechanism so as to extend the mechanism, such as specifying response codes, HTTP headers or custom documentation. """ description = String() body = Map(String(), Reference(RamlBody)) headers = RamlNamedParametersMap() queryParameters = RamlNamedParametersMap() responses = Map(Int(), Reference(RamlResponse)) baseUriParameters = RamlNamedParametersMap() protocols = List( Choice(field_name='protocols', choices=RAML_VALID_PROTOCOLS))
class RamlRoot(SecuredEntity, Model): """ http://raml.org/spec.html#root-section """ raml_version = String(required=True) title = String(required=True) version = Or(String(), Int(), Float()) baseUri = String(required=True) protocols = List( Choice(field_name='protocols', choices=RAML_VALID_PROTOCOLS)) mediaType = String() documentation = List(Reference(RamlDocumentation)) traits = Map(String(), Reference(RamlTrait)) resources = Map(String(), Reference(RamlResource)) resourceTypes = Map(String(), Reference(RamlResourceType)) schemas = Map(String(), Or(JSONData(), XMLData(), String())) baseUriParameters = RamlNamedParametersMap() securitySchemes = Map(String(), Reference(RamlSecurityScheme))
class RamlResponse(Model): schema = String() example = String() notNull = Bool() description = String() headers = Map(String(), Reference(RamlHeader)) body = Reference("pyraml.entities.RamlBody")
class RamlResourceType(Model): """ A resource type is a partial resource definition that, like a resource, can specify a description and methods and their properties. """ usage = String() description = String() methods = Map(String(), Reference(RamlMethod))
class RamlResponse(Model): """ Responses MUST be a map of one or more HTTP status codes, where each status code itself is a map that describes that status code. """ notNull = Bool() description = String() headers = RamlNamedParametersMap() body = Map(String(), Reference("pyraml.entities.RamlBody"))
class RamlTrait(Model): """ A trait is a partial method definition that, like a method, can provide method-level properties such as description, headers, query string parameters, and responses. """ usage = String() description = String() headers = RamlNamedParametersMap() queryParameters = RamlNamedParametersMap() responses = Map(Int(), Reference(RamlResponse))
class RamlTrait(Model): """ traits: - secured: usage: Apply this to any method that needs to be secured description: Some requests require authentication. queryParameters: access_token: description: Access Token type: string example: ACCESS_TOKEN required: true """ name = String() usage = String() description = String() displayName = String() responses = Map(Int(), Reference(RamlResponse)) method = String() queryParameters = Map(String(), Reference(RamlQueryParameter)) body = Reference(RamlBody) # Reference to another RamlTrait is_ = List(String(), field_name="is")
class RamlMethod(Model): notNull = Bool() description = String() body = Reference(RamlBody) responses = Map(Int(), Reference(RamlBody))
class SecuredEntity(object): # [foo, {bar: {baz: [buz]}}, null] securedBy = List( Or(String(), Map(String(), Map(String(), List(String()))), Null()))
class ResourceTypedEntity(object): """ Represents entities that may have resourceTypes specified in ``type`` field. """ type = Or(String(), Map(String(), Map(String(), String())))
class RamlResourceType(Model): methods = Map(String(), Reference(RamlTrait)) type = String() is_ = List(String(), field_name="is")
class RamlSecurityScheme(Model): """ http://raml.org/spec.html#security """ description = String() type = String() describedBy = Reference(RamlSecuritySchemeDescription) settings = Map(String(), Or(String(), List(String())))
class TraitedEntity(object): """ Represents entities that may have traits specified in ``is`` field. """ is_ = List(Or(String(), Map(String(), Map(String(), String()))), field_name='is')