-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'input-type-doc' into 'master'
Input type doc - Ignore mime-types accept for GET, HEAD and DELETE operation docs - We'll probably revert this eventually - Check this out: OAI/OpenAPI-Specification#1937 - Add accepted mime-types to operation doc - Add request type filtering to readme - Add default permissive request body description to doc generation - Fix unknown type "as-is" on cli options - Move accepts type parsing to own file - Update test suite to listen based on a constant instead of explicit 'localhost' See merge request GCSBOSS/nodecaf!20
- Loading branch information
Showing
8 changed files
with
250 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const assert = require('assert'); | ||
const mime = require('mime/lite'); | ||
|
||
// Define shortcut extensions for supported mime-types. | ||
mime.define({ | ||
'application/x-www-form-urlencoded': ['urlencoded'], | ||
'multipart/form-data': ['form'] | ||
}); | ||
|
||
module.exports = { | ||
|
||
/* o\ | ||
Parse the @types and convert any file extension to it's matching | ||
mime-type. In case @types is a string, a single element array will be | ||
produced. | ||
\o */ | ||
parseTypes(types){ | ||
types = typeof types == 'string' ? [types] : types; | ||
assert(Array.isArray(types)); | ||
types = types.map( t => mime.getType(t) || t); | ||
return types; | ||
} | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.