Merge branch 'master' into master

This commit is contained in:
Ron
2017-10-20 16:54:03 -07:00
committed by GitHub
22 changed files with 225 additions and 246 deletions

View File

@@ -31,6 +31,7 @@ export default Markdown
const sanitizeOptions = {
allowedTags: sanitize.defaults.allowedTags.concat([ "h1", "h2", "img" ]),
allowedAttributes: {
...sanitize.defaults.allowedAttributes,
"img": sanitize.defaults.allowedAttributes.img.concat(["title"])
},
textFilter: function(text) {

View File

@@ -10,7 +10,7 @@ export const shownDefinitions = createSelector(
export const definitionsToAuthorize = createSelector(
state,
() =>( { specSelectors } ) => {
() => ( { specSelectors } ) => {
let definitions = specSelectors.securityDefinitions()
let list = List()
@@ -27,7 +27,7 @@ export const definitionsToAuthorize = createSelector(
)
export const getDefinitionsByNames = ( state, securities ) =>( { specSelectors } ) => {
export const getDefinitionsByNames = ( state, securities ) => ( { specSelectors } ) => {
let securityDefinitions = specSelectors.securityDefinitions()
let result = List()
@@ -64,7 +64,7 @@ export const authorized = createSelector(
)
export const isAuthorized = ( state, securities ) =>( { authSelectors } ) => {
export const isAuthorized = ( state, securities ) => ( { authSelectors } ) => {
let authorized = authSelectors.authorized()
if(!List.isList(securities)) {

View File

@@ -6,7 +6,7 @@ import { isOAS3 as isOAS3Helper } from "../helpers"
// Helpers
function onlyOAS3(selector) {
return (ori, system) => (...args) => {
return (ori, system) => (state, ...args) => {
const spec = system.getSystem().specSelectors.specJson()
if(isOAS3Helper(spec)) {
return selector(...args)
@@ -20,7 +20,7 @@ const nullSelector = createSelector(() => null)
const OAS3NullSelector = onlyOAS3(nullSelector)
// Hasta la vista, authentication!
// Hasta la vista, authorization!
export const shownDefinitions = OAS3NullSelector
export const definitionsToAuthorize = OAS3NullSelector
export const getDefinitionsByNames = OAS3NullSelector

View File

@@ -137,10 +137,13 @@ export function changeParam( path, paramName, paramIn, value, isXml ){
}
}
export function validateParams( payload ){
export const validateParams = ( payload, isOAS3 ) =>{
return {
type: VALIDATE_PARAMS,
payload:{ pathMethod: payload }
payload:{
pathMethod: payload,
isOAS3
}
}
}

View File

@@ -51,14 +51,14 @@ export default {
})
},
[VALIDATE_PARAMS]: ( state, { payload: { pathMethod } } ) => {
[VALIDATE_PARAMS]: ( state, { payload: { pathMethod, isOAS3 } } ) => {
let operation = state.getIn( [ "resolved", "paths", ...pathMethod ] )
let isXml = /xml/i.test(operation.get("consumes_value"))
return state.updateIn( [ "resolved", "paths", ...pathMethod, "parameters" ], fromJS([]), parameters => {
return parameters.withMutations( parameters => {
for ( let i = 0, len = parameters.count(); i < len; i++ ) {
let errors = validateParam(parameters.get(i), isXml)
let errors = validateParam(parameters.get(i), isXml, isOAS3)
parameters.setIn([i, "errors"], fromJS(errors))
}
})

View File

@@ -13,3 +13,7 @@ export const executeRequest = (ori, { specActions }) => (req) => {
specActions.logRequest(req)
return ori(req)
}
export const validateParams = (ori, { specSelectors }) => (req) => {
return ori(req, specSelectors.isOAS3())
}

View File

@@ -537,16 +537,18 @@ export const validateMinLength = (val, min) => {
}
// validation of parameters before execute
export const validateParam = (param, isXml) => {
export const validateParam = (param, isXml, isOAS3 = false) => {
let errors = []
let value = isXml && param.get("in") === "body" ? param.get("value_xml") : param.get("value")
let required = param.get("required")
let maximum = param.get("maximum")
let minimum = param.get("minimum")
let type = param.get("type")
let format = param.get("format")
let maxLength = param.get("maxLength")
let minLength = param.get("minLength")
let paramDetails = isOAS3 ? param.get("schema") : param
let maximum = paramDetails.get("maximum")
let minimum = paramDetails.get("minimum")
let type = paramDetails.get("type")
let format = paramDetails.get("format")
let maxLength = paramDetails.get("maxLength")
let minLength = paramDetails.get("minLength")
/*
If the parameter is required OR the parameter has a value (meaning optional, but filled in)
@@ -616,7 +618,7 @@ export const validateParam = (param, isXml) => {
if ( !value.count() ) { return errors }
itemType = param.getIn(["items", "type"])
itemType = paramDetails.getIn(["items", "type"])
value.forEach((item, index) => {
let err

View File

@@ -772,14 +772,6 @@
}
}
.renderedMarkdown {
p {
@include text_body();
margin-top: 0px;
margin-bottom: 0px;
}
}
.response-content-type {
padding-top: 1em;