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 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 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 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 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 RamlQueryParameter(Model): name = String() description = String() example = Or(String(),Int(),Float()) displayName = String() type = String() enum = List(Or(String(),Float(),Int())) pattern = String() minLength = Int() maxLength = Int() repeat = Bool() required = Bool() default = Or(String(),Int(),Float()) minimum = Or(Int(),Float()) maximum = Or(Int(),Float())
class RamlNamedParameters(Model): """ http://raml.org/spec.html#named-parameters """ displayName = String() description = String() type = Choice(default='string', choices=NAMED_PARAMETER_TYPES) name = String() example = Or(String(), Int(), Float()) enum = List(Or(String(), Float(), Int())) pattern = String() minLength = Int() maxLength = Int() repeat = Bool() required = Bool() default = Or(String(), Int(), Float()) minimum = Or(Int(), Float()) maximum = Or(Int(), Float())
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 SecuredEntity(object): # [foo, {bar: {baz: [buz]}}, null] securedBy = List( Or(String(), Map(String(), Map(String(), List(String()))), Null()))
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')
class RamlResourceType(Model): methods = Map(String(), Reference(RamlTrait)) type = String() is_ = List(String(), field_name="is")