// // BlueprintSourcemap.h // snowcrash // // Created by Pavan Kumar Sunkara on 26/8/14. // Copyright (c) 2014 Apiary Inc. All rights reserved. // #ifndef SNOWCRASH_BLUEPRINT_SOURCEMAP_H #define SNOWCRASH_BLUEPRINT_SOURCEMAP_H #include "Blueprint.h" #include "MarkdownParser.h" /** * API Blueprint Sourcemap Abstract Syntax Tree * --------------------------------------------- * * Data types in this documents define the API Blueprint Sourcemap AST. */ #define SOURCE_MAP_COLLECTION(T, TC) template<>\ struct SourceMap {\ Collection >::type collection;\ };\ namespace snowcrash { struct SourceMapBase { mdp::BytesRangeSet sourceMap; }; template struct SourceMap : public SourceMapBase { }; /** Source Map of Metadata Collection */ SOURCE_MAP_COLLECTION(Metadata, MetadataCollection) /** Source Map of Headers */ // 'Metadata' type is same as 'Header' /** Source Map of Collection of Parameter values */ SOURCE_MAP_COLLECTION(Value, Values) /** Source Map Structure for Parameter */ template<> struct SourceMap : public SourceMapBase { /** Source Map of Parameter Name */ SourceMap name; /** Source Map of Parameter Description */ SourceMap description; /** Source Map of Parameter Type */ SourceMap type; /** Source Map of Required flag */ SourceMap use; /** Source Map of Default Value, applicable only when `required == false` */ SourceMap defaultValue; /** Source Map of Example Value */ SourceMap exampleValue; /** Enumeration of possible values */ SourceMap values; }; /** Source Map of Collection of Parameters */ SOURCE_MAP_COLLECTION(Parameter, Parameters) /** * Source Map Structure for Payload */ template<> struct SourceMap : public SourceMapBase { /** Source Map of a Payload Name */ SourceMap name; /** Source Map of Payload Description */ SourceMap description; /** Payload-specific Parameters */ SourceMap parameters; /** Payload-specific Headers */ SourceMap headers; /** Source Map of Body */ SourceMap body; /** Source Map of Schema */ SourceMap schema; /** Source Map of Symbol */ SourceMap reference; }; /** Source Map of Collection of Requests */ SOURCE_MAP_COLLECTION(Request, Requests) /** Source Map of Collection of Responses */ // 'Response' type is same as 'Request' /** * Source Map Structure for an HTTP transaction example. */ template<> struct SourceMap : public SourceMapBase { /** Source Map of an example name */ SourceMap name; /** Source Map of Description */ SourceMap description; /** Requests */ SourceMap requests; /** Responses */ SourceMap responses; }; /** Source Map of Collection of Transaction examples */ SOURCE_MAP_COLLECTION(TransactionExample, TransactionExamples) /** * Source Map Structure for Action */ template<> struct SourceMap : public SourceMapBase { /** Source Map of HTTP method */ SourceMap method; /** Source Map of an Action name */ SourceMap name; /** Source Map of Description */ SourceMap description; /** Action-specific Parameters */ SourceMap parameters; /** * \brief Action-specific HTTP headers * * DEPRECATION WARNING: * -------------------- * * This AST node is build for deprecated API Blueprint syntax * and as such it will be removed in a future version of * Snow Crash. * * Use respective payload's header collection instead. */ DEPRECATED SourceMap headers; /** Transactions examples */ SourceMap examples; }; /** Source Map of Collection of Actions */ SOURCE_MAP_COLLECTION(Action, Actions) /** * Source Map Structure for API Resource */ template<> struct SourceMap : public SourceMapBase { /** Source Map of URI template */ SourceMap uriTemplate; /** Source Map of a Resource Name */ SourceMap name; /** Source Map of Description of the resource */ SourceMap description; /** Model representing this Resource */ SourceMap model; /** Parameters */ SourceMap parameters; /** * \brief Resource-specific HTTP Headers * * DEPRECATION WARNING: * -------------------- * * This AST node is build for deprecated API Blueprint syntax * and as such it will be removed in a future version of * Snow Crash. * * Use respective payload's header collection instead. */ DEPRECATED SourceMap headers; /** A set of Actions specified for this Resource */ SourceMap actions; }; /** Source Map of Collection of Resources */ SOURCE_MAP_COLLECTION(Resource, Resources) /** * Source Map Structure for Group of API Resources */ template<> struct SourceMap : public SourceMapBase { /** Source Map of a Group Name */ SourceMap name; /** Source Map of Group description */ SourceMap description; /** Resources */ SourceMap resources; }; /** Source Map of Collection of Resource groups */ SOURCE_MAP_COLLECTION(ResourceGroup, ResourceGroups) /** * \brief API Blueprint Sourcemap AST * * This is top-level (or root if you prefer) of API Blueprint Sourcemap abstract syntax tree. * Start reading a parsed API here. */ template<> struct SourceMap : public SourceMapBase { /** Source Map of API Blueprint metadata */ SourceMap metadata; /** Source Map of the API Name */ SourceMap name; /** Source Map of an API Overview description */ SourceMap description; /** The set of API Resource Groups */ SourceMap resourceGroups; }; } #endif