GithubHelp home page GithubHelp logo

services_documentation's Introduction

Project Description
================================================================================

Overview
--------------------------------------------------------------------------------
The Services Documentation module generates API documentation for your site's
Services resources. Most of the documentation is generated automatically, using
the resource information contained provided by Services. However, this module
provides you with the ability to easily extend that documentation.

We make the following assumptions about your usage of the Services module:

* You are providing an API to a third party, which allows them to access your
  data via Services.
* Your API will be organized by version. E.g., API version 1.x, 2.x, etc.
* You would like to provide a page to API consumers that documents your API
  endpoints, resources, etc.
* You have enough familiarity with Drupal to create a module and implement a
  hook.

Documentation will be made available on your Drupal site at /developers. It will
be organized by API version (arbitrarily defined by you), and subsequently
displayed hierarchically according to resource, method type, method name,
arguments, etc.

Usage
--------------------------------------------------------------------------------
A full example implementation can be found in
services_documentation/services_documentation.api.php

* Create a new, custom module. Let's call it myapi.module.
* Implement hook_services_resources_alter($resources);
* For each resource method that you would like to document, add two new rows to
  the $resource array: ‘documentation callback' and 'documentation versions'.
  <pre>
    $resources['user']['index']['documentation callback'] = '_myapi_index_doc';
    $resources['user']['index']['documentation versions'] = array(1000);
  </pre>
* Define the documentation callback, which should return an element in the
  following format:
  <pre>
  /**
   * Documentation callback for index operation of users resource.
   */
  function _myapi_uses_index_doc() {
    $element = array(
      '#name' => t('name'),
      '#description' => t('desc'),
      // Example request. E.g., a request URL, headers, and a JSON array.
      '#request' => t('request'),
      // Example response. E.g., a JSON array.
      '#response' => t('response'),
    );

    return $element;
  }
  </pre>

After enabling this module, a list of API version numbers will appear at
/developers. Clicking on the version number will display a list of resources,
their arguments, endpoints, etc.

Contributing
--------------------------------------------------------------------------------
Anyone is encouraged to contribute to this project.

By contributing to this project, you grant a world-wide, royalty-free,
perpetual, irrevocable, non-exclusive, transferable license to all users under
the terms of the Gnu General Public License v2 or later.

All comments, messages, pull requests, and other submissions received through
official White House pages including this Drupal.org page are subject to the
Presidential Records Act and may be archived. Learn more at
http://whitehouse.gov/privacy.

License
--------------------------------------------------------------------------------
This project constitutes a work of the United States Government and is not
subject to domestic copyright protection under 17 USC § 105.

The project utilizes code licensed under the terms of the GNU General Public
License and therefore is licensed under GPL v2 or later.

This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 2 of the License, or (at your option) any later
version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with
this program. If not, see http://www.gnu.org/licenses/.

services_documentation's People

Contributors

grasmash avatar theneonlobster avatar traviscarden avatar nhepner1 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.