npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

grunt-apiblueprint-springmvc

v0.2.2

Published

Allows execution of the apiblueprint-springmvc generator, to generate SpringMVC source files from an apiblueprint specification.

Downloads

17

Readme

Travis CI Build Status

grunt-apiblueprint-springmvc

Allows execution of the apiblueprint-springmvc generator, to generate SpringMVC source files from an apiblueprint specification.

Getting Started

This plugin requires Grunt. It also assumes that you have an understanding of API Blueprint, so that you can write apib files for this plugin to process!

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-apiblueprint-springmvc --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-apiblueprint-springmvc');

The "apiblueprint_springmvc" task

Overview

In your project's Gruntfile, add a section named apiblueprint_springmvc to the data object passed into grunt.initConfig().

grunt.initConfig({
  apiblueprint_springmvc: {
    options: {
      // Your options options go here.
    },
    files: {
      'destinationPath': ['src/*.apib']
    }
  }
});

Options

options.includePath

Default: process.cwd()

If your apib files use the aglio include directive, files will be included relative to this path.

options.filterInput

Default: true

If true, tabs will be replaced with 4 spaces prior to processing, and windows newlines converted to linux (required, since APIB doesn't support tabs or windows).

options.encoding

Default: utf8

The encoding of input .apib files.

options.packagePrefix

Default: api

The java package that will be inserted to the top of each java file.

options.extraImports

Default: []

An array of strings, which will be inserted at the top of the java Controllers and Service Interface. Each string should be a full java class name, or other valid value for an import statement.

Example: ['api.rest.model.response.','api.rest.model.request.']

options.skipModelNames

Default: []

An array of model names that should not have java files created for them, in the models directory. This is useful if you do not want to generate files for some types that are defined in the apib (foe example, they are defined already in the java project elsewhere)

options.flattenParentClasses

Default: false

If true, instead of using class inheritance, models will be flattened to contain all parent model fields.

options.resourceModifiers

Default: []

An array of objects that you can use to add extra annotations, or parameters to a controller method.

Each array entry contains a matching rule (exact match or regular expression) to determine which controller methods should have the modifier applied. The method name against which the rule matches is in the format ControllerName.methodName

The modifier itself can apply an annotation to the method itself, or add (optionally) annotated parameters to the method signature (either at the beginning, or end, of the parameter list.)

The modifier definition is as follows:

{
    pattern: /MyController\..+/,
    methodAnnotations: ['@AnnoOne', '@AnnoTwo("someArg")'],
    prependedParameters: [ { type: 'HttpServletRequest', name: 'prefixedParam' } ],
    appendedParameters: [ { annotation: '@NotNull', type: 'HttpServletResponse', name: 'suffixedParam' } ]
}

This would result in the following output (assuming it matched a method with a single parameter, original)

@AnnoOne
@AnnoTwo("someArg")
@RequestMapping("/someMethod{original}")
public ReturnObject someMethod(HttpServletRequest prefixedParam, @PathVariable String original, @NotNull HttpServletResponse suffixedParam) {
    return delegateService.someMethod(prefixedParam, original, suffixedParam);
}

pattern is either a string (for exact match) or a regular expression.

methodAnnotations contains a list of strings; each which is inserted verbatim above the method definiton.

prependedParameters contains a list of objects. Mandatory fields are type and name ; however annotation is optional.

appendedParameters contains a list of objects. Mandatory fields are type and name ; however annotation is optional.

Usage Examples

Default Options

In this example, the most commonly used options are specified. This will

grunt.initConfig({
  apiblueprint_springmvc: {
    options: {
      includePath: 'src',
      packagePrefix: 'my.package.rest',
      extraImports: ['my.package.rest.model.response.*','my.package.rest.model.request.*'],
      skipModelNames: ['ReadSingleResponse', 'ReadListResponse', 'OperationResponse', 'FilterableRequest']
    },
    files: {
      'destinationPath': ['src/*.apib']
    },
  },
})

Roadmap

Some things I would like to add

  • Hook the generator into the grunt logger

Contributing

Pull requests are welcome!

Release History

(Nothing yet)

License

Copyright (c) 2015 Lewis Weaver. Licensed under the MIT license.