Skip to content
Permalink
Browse files

dereference the swagger spec (#43)

  • Loading branch information...
msluther authored and jcrugzz committed Mar 20, 2019
1 parent c35d126 commit d120fa32be80f3d85b63341f39ee0d1537c3c4d7
Showing with 215 additions and 22 deletions.
  1. +1 −1 .gitignore
  2. +1 −1 .npmignore
  3. +18 −0 bin/swagger
  4. +2 −1 lib/npm/publisher.js
  5. +10 −0 lib/npm/routes.js
  6. +6 −1 lib/routes/builds.js
  7. +2 −1 lib/routes/packages.js
  8. +2 −0 lib/routes/release-line.js
  9. +24 −16 lib/routes/swagger.js
  10. +147 −0 package-lock.json
  11. +2 −1 package.json
@@ -40,4 +40,4 @@ npm-error.log
.node_repl_history

# swagger docs
lib/swagger.json
lib/wrhs-spec.json
@@ -40,4 +40,4 @@ npm-error.log
.node_repl_history

# swagger docs
!lib/swagger.json
!lib/wrhs-spec.json
@@ -0,0 +1,18 @@
#!/usr/bin/env node

// TODO: extract into npm package
const path = require('path');
const fs = require('fs');
const swaggerDoc = require('swagger-jsdoc');
const jsonRefs = require('json-refs');

const source = require('../lib/swagger.js');
const options = { ...source, swaggerDefinition: source };
delete options.swaggerDefinition.apis;
const rawSpec = swaggerDoc(options);
jsonRefs.resolveRefs(rawSpec)
.then(spec => {
fs.writeFileSync(path.join(__dirname, '..', 'lib', 'wrhs-spec.json'), JSON.stringify(spec.resolved, null, 2));
});


@@ -88,7 +88,8 @@ Publisher.prototype.setup = function () {
* description: The npm publish payload
* responses:
* $ref: '#/responses/Standard'
*/ this.router = params(new Router())
*/
this.router = params(new Router())
.put('/:pkg', this.auth, this.verify.bind(this));

this.request = require('hyperquest');
@@ -83,6 +83,8 @@ module.exports = function (app) {
* $ref: '#/definitions/DistTags'
* 400:
* $ref: '#/responses/Standard400'
* 401:
* $ref: '#/responses/Standard401'
* 403:
* $ref: '#/responses/Standard403'
* 404:
@@ -139,6 +141,8 @@ module.exports = function (app) {
* description: Success
* 400:
* $ref: '#/responses/Standard400'
* 401:
* $ref: '#/responses/Standard401'
* 403:
* $ref: '#/responses/Standard403'
* 404:
@@ -165,6 +169,8 @@ module.exports = function (app) {
* $ref: '#/definitions/DistTags'
* 400:
* $ref: '#/responses/Standard400'
* 401:
* $ref: '#/responses/Standard401'
* 403:
* $ref: '#/responses/Standard403'
* 404:
@@ -191,6 +197,8 @@ module.exports = function (app) {
* $ref: '#/definitions/DistTags'
* 400:
* $ref: '#/responses/Standard400'
* 401:
* $ref: '#/responses/Standard401'
* 403:
* $ref: '#/responses/Standard403'
* 404:
@@ -226,6 +234,8 @@ module.exports = function (app) {
* $ref: '#/responses/Standard304'
* 400:
* $ref: '#/responses/Standard400'
* 401:
* $ref: '#/responses/Standard401'
* 403:
* $ref: '#/responses/Standard403'
* 404:
@@ -69,13 +69,14 @@ module.exports = function (app) {
* $ref: '#/definitions/Builds'
* 400:
* $ref: '#/responses/Standard400'
* 401:
* $ref: '#/responses/Standard401'
* 403:
* $ref: '#/responses/Standard403'
* 404:
* $ref: '#/responses/Standard404'
* 500:
* $ref: '#/responses/Standard500'
*/

/**
@@ -203,6 +204,8 @@ module.exports = function (app) {
* $ref: '#/definitions/Meta'
* 400:
* $ref: '#/responses/Standard400'
* 401:
* $ref: '#/responses/Standard401'
* 403:
* $ref: '#/responses/Standard403'
* 404:
@@ -404,6 +407,8 @@ module.exports = function (app) {
* description: Success
* 400:
* $ref: '#/responses/Standard400'
* 401:
* $ref: '#/responses/Standard401'
* 403:
* $ref: '#/responses/Standard403'
* 404:
@@ -37,13 +37,14 @@ module.exports = function (app) {
* $ref: '#/definitions/Packages'
* 400:
* $ref: '#/responses/Standard400'
* 401:
* $ref: '#/responses/Standard401'
* 403:
* $ref: '#/responses/Standard403'
* 404:
* $ref: '#/responses/Standard404'
* 500:
* $ref: '#/responses/Standard500'
*/

/**
@@ -29,6 +29,8 @@ module.exports = function (app) {
* $ref: '#/definitions/ReleaseLine'
* 400:
* $ref: '#/responses/Standard400'
* 401:
* $ref: '#/responses/Standard401'
* 403:
* $ref: '#/responses/Standard403'
* 404:
@@ -1,6 +1,6 @@
'use strict';
const swaggerUI = require('swagger-ui-express');
const swaggerDefs = require('../swagger.json');
const swaggerDefs = require('../wrhs-spec.json');

module.exports = function (app) {
//
@@ -44,6 +44,16 @@ module.exports = function (app) {
* type: string
* minimum: 1
*
* Error:
* application/json:
* schema:
* type: object
* properties:
* code:
* type: string
* message:
* type: string
*
* parameters:
* Pkg:
* in: path
@@ -67,46 +77,44 @@ module.exports = function (app) {
* $ref: '#/definitions/VersionNumber'
* description: The package version
*
* content:
* Error:
* application/json:
* schema:
* type: object
* properties:
* code:
* type: string
* message:
* type: string
* responses:
* Standard:
* 200:
* description: OK
* $ref: '#/responses/Standard200'
* 400:
* $ref: '#/responses/Standard400'
* 401:
* $ref: '#/responses/Standard401'
* 403:
* $ref: '#/responses/Standard403'
* 404:
* $ref: '#/responses/Standard404'
* 500:
* $ref: '#/responses/Standard500'
* Standard200:
* description: OK
* Standard304:
* description: Not Modified
* Standard400:
* description: Bad Request
* content:
* $ref: '#/content/Error'
* $ref: '#/definitions/Error'
* Standard401:
* description: Unauthorized
* content:
* $ref: '#/definitions/Error'
* Standard403:
* description: Forbidden
* content:
* $ref: '#/content/Error'
* $ref: '#/definitions/Error'
* Standard404:
* description: Not Found
* content:
* $ref: '#/content/Error'
* $ref: '#/definitions/Error'
* Standard500:
* description: Internal Server Error
* content:
* $ref: '#/content/Error'
* $ref: '#/definitions/Error'
*
*/

Oops, something went wrong.

0 comments on commit d120fa3

Please sign in to comment.
You can’t perform that action at this time.