How to use openapi-default-setter - 2 common examples

To help you get started, we’ve selected a few openapi-default-setter examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aimed / slushy / server / src / middleware / RequestDefaultValueSetterMiddlewareFactory.ts View on Github external
if (!operation) {
            throw new Error('RequestCoercionMiddlewareFactory requires operation')
        }

        let operationObject: OpenAPIV3.OperationObject
        try {
            operationObject = getOperationObject(props.openApi, path, operation)
        } catch (_error) {
            return []
        }

        // FIXME: Handle reference objects
        const parameters = (operationObject.parameters || []).filter(
            val => !isReferenceObject(val),
        ) as OpenAPIV3.ParameterObject[]
        const defaultSetter = new OpenAPIDefaultSetter({
            parameters,
        })
        return [
            (req, _res, next) => {
                defaultSetter.handle(req)
                next()
            },
        ]
    }
}
github kogosoftwarellc / open-api / packages / openapi-framework / index.ts View on Github external
operationContext.features.coercer = coercer;
              }

              // no point in default feature if we don't have any parameters with defaults.
              if (
                methodParameters.filter(byDefault).length &&
                allowsDefaultsFeature(
                  this,
                  this.apiDoc,
                  pathModule,
                  pathDoc,
                  operationDoc
                )
              ) {
                const defaultSetter = new OpenAPIDefaultSetter({
                  parameters: methodParameters
                });
                operationContext.features.defaultSetter = defaultSetter;
              }
            }

            let securityFeature;
            let securityDefinition;

            if (this.securityHandlers && securitySchemes) {
              if (operationDoc.security) {
                securityDefinition = operationDoc.security;
              } else if (this.pathSecurity.length) {
                securityDefinition = getSecurityDefinitionByPath(
                  openapiPath,
                  this.pathSecurity

openapi-default-setter

Sets default values in request properties according to defaults defined in openapi parameter lists.

MIT
Latest version published 11 months ago

Package Health Score

72 / 100
Full package analysis

Popular openapi-default-setter functions