diff --git a/features/api_blueprint_documentation.feature b/features/api_blueprint_documentation.feature index b78e19ef..39c5073a 100644 --- a/features/api_blueprint_documentation.feature +++ b/features/api_blueprint_documentation.feature @@ -115,6 +115,11 @@ Feature: Generate API Blueprint documentation from test examples attribute :name, 'The order name', required: true, :example => 'a name' attribute :amount, required: false attribute :description, 'The order description', type: 'string', required: false, example: "a description" + attribute :category, 'The order category', type: 'string', required: false, default: 'normal', enum: %w[normal priority] + attribute :metadata, 'The order metadata', type: 'json', required: false, annotation: <<-MARKDOWN + + instructions (optional, string) + + notes (optional, string) + MARKDOWN get 'Returns a single order' do explanation "This is used to return orders." @@ -360,6 +365,14 @@ Feature: Generate API Blueprint documentation from test examples + name: a name (required) - The order name + amount (optional) + description: a description (optional, string) - The order description + + category (optional, string) - The order category + + Default: `normal` + + Members + + `normal` + + `priority` + + metadata (optional, json) - The order metadata + + instructions (optional, string) + + notes (optional, string) ### Deletes a specific order [DELETE] diff --git a/lib/rspec_api_documentation/views/api_blueprint_index.rb b/lib/rspec_api_documentation/views/api_blueprint_index.rb index 3c36082a..ef42c1fa 100644 --- a/lib/rspec_api_documentation/views/api_blueprint_index.rb +++ b/lib/rspec_api_documentation/views/api_blueprint_index.rb @@ -86,6 +86,11 @@ def fields(property_name, examples) property[:properties_description] = nil end + property[:has_default?] = true if property[:default] + property[:has_enum?] = true if property[:enum] + + property[:annotations] = property[:annotation].lines.map(&:chomp) if property[:annotation] + property[:description] = nil if description_blank?(property) property end diff --git a/templates/rspec_api_documentation/api_blueprint_index.mustache b/templates/rspec_api_documentation/api_blueprint_index.mustache index 865f24a3..ac992c73 100644 --- a/templates/rspec_api_documentation/api_blueprint_index.mustache +++ b/templates/rspec_api_documentation/api_blueprint_index.mustache @@ -27,6 +27,18 @@ explanation: {{ explanation }} + Parameters {{# parameters }} + {{ name }}{{# example }}: {{ example }}{{/ example }}{{# properties_description }} ({{ properties_description }}){{/ properties_description }}{{# description }} - {{ description }}{{/ description }} + {{# has_default?}} + + Default: `{{default}}` + {{/ has_default?}} + {{# has_enum?}} + + Members + {{# enum}} + + `{{.}}` + {{/ enum}} + {{/ has_enum?}} + {{# annotations }} + {{ . }} + {{/ annotations }} {{/ parameters }} {{/ has_parameters? }} {{# has_attributes? }} @@ -34,6 +46,18 @@ explanation: {{ explanation }} + Attributes (object) {{# attributes }} + {{ name }}{{# example }}: {{ example }}{{/ example }}{{# properties_description }} ({{ properties_description }}){{/ properties_description }}{{# description }} - {{ description }}{{/ description }} + {{# has_default?}} + + Default: `{{default}}` + {{/ has_default?}} + {{# has_enum?}} + + Members + {{# enum}} + + `{{.}}` + {{/ enum}} + {{/ has_enum?}} + {{# annotations }} + {{ . }} + {{/ annotations }} {{/ attributes }} {{/ has_attributes? }} {{# http_methods }}