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

support multiple tags as an array and in definition #30

Merged
merged 2 commits into from
Aug 30, 2016

Conversation

efmr
Copy link
Contributor

@efmr efmr commented Aug 11, 2016

Allow to set multiple tags in jsdoc with as an array
It will allow definition of tags in swagger definition and will merge with others in the jsdoc.

* /login:
* post:
* description: Login to the application
* tag: [Users]
* tag: [Users, Login]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this support yaml array syntax?

Copy link
Contributor Author

@efmr efmr Aug 27, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@drGrove Yes it does.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@efmr, would you mind writing a test for this so we make sure that we don't get a regression in the future?

Copy link
Contributor Author

@efmr efmr Aug 29, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@drGrove Alright, just did it ce6a493 .

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @efmr, I'll merge this tonight unless @chdanielmueller says otherwise.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@drGrove fine with me

@drGrove drGrove merged commit 2ea4993 into Surnet:master Aug 30, 2016
@cguedes
Copy link

cguedes commented Aug 31, 2016

Hi. First, great work here. This project is very nice.

I've noticed that you are using tag instead of tags in the examples for operations (https://github.com/Surnet/swagger-jsdoc/blob/2ea4993ace5cc268428666a9119b09e21585e3a9/example/routes.js#L55).
Check the Operation Object of swagger spec to see that we should use tags instead.

@kalinchernev
Copy link
Contributor

Hi @cguedes, I looked now at the "Operation Object of swagger spec" link, yes, you're correctly pointing out that the final output has to have the tags property (plural)
There's an open issue #33 which is related, and as far as i see it's outputting a plural for of a property.
Do you comment only about the examples files? In also about the implementation?

@cguedes
Copy link

cguedes commented Aug 31, 2016

TLDR: I'm talking about example files.

There are two places where tags are defined in the swagger spec. The list of all tags:

  1. In the field tags at the root of the spec
    info: {
      'title': 'Hello Word',
      'description': 'This is a sample server Petstore server.',
    },
    tags:[
      {
        'name': 'user',
        'description': 'User APIs'
      },
      {
        'name': 'setting',
        'description': 'Setting APIs'
      }
    ],
    basePath: '/api'
  }

This is ok.

  1. In the operation object that is "A list of tags for API documentation control. Tags can be used for logical grouping of operations by resources or any other qualifier." of type [string].

This second should be defined per API using JSDOC with the following:

  /**
   * @swagger
   * /login:
   *   post:
   *     description: Login to the application
   *     tags: [Users, Login]
   *     produces:
   *       - application/json
   */

instead of

  /**
   * @swagger
   * /login:
   *   post:
   *     description: Login to the application
   *     tag: [Users, Login]
   *     produces:
   *       - application/json
   */

At the moment you are not validating this, so people can change, but following the example they may end up with issues regarding this change (like myself).

@efmr
Copy link
Contributor Author

efmr commented Aug 31, 2016

I suggest you create a separate issue on this subject. There is definitely a point to keeping the jsdoc as similar as possible to the specification it produces.

Wouldn't this also apply to other properties such as response and parameter? Check: https://github.com/Surnet/swagger-jsdoc/blob/master/lib/index.js#L105.

@kalinchernev
Copy link
Contributor

@cguedes thanks a lot of the details, I linked them in the issue
@efmr makes sense indeed, I'll have look to having validations on the specification-specific :) properties
Thanks for the input!

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

5 participants