Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow each method of a service to define docs. #52

Merged
merged 1 commit into from
Apr 13, 2017

Conversation

cpsubrian
Copy link
Contributor

@cpsubrian cpsubrian commented Apr 4, 2017

Simple change that allows for an alternative syntax in services that in some cases would read better (IMO). Example (with a theoretical decorator that we could even ship):

@docs({
  description: 'My cool service.'
})
class MyService {
  @docs({
    description: 'Create the cool thing.',
    parameters: [],
    responses: {}
  })
  create () {
    // Do the thing
  }

  @docs({
    description: 'Find cool things.',
    parameters: [],
    responses: {}
  })
  find () {
    // Do the thing
  }
}

Or just use getters in a clever fashion.

class MyService {
  get docs () {
    return {
      description: 'My cool service.'
    }
  }

  get create () {
    return Object.assign(this._create, {
      docs: {
        description: 'Create the cool thing.',
        parameters: [],
        responses: {}
      }
    })
  }
  _create () {
    // Do the thing
  }

  get find () {
    return Object.assign(this._find, {
      docs: {
        description: 'Find cool things.',
        parameters: [],
        responses: {}
      }
    })
  }
  _find () {
    // Do the thing
  }
}

@daffl daffl merged commit 701eb7b into feathersjs-ecosystem:master Apr 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants