Manually register the Pippo Error class as  Swagger model.

@param swagger
@return a ref for the Error model
558386
protected RefProperty registerErrorModel(Swagger swagger) {
        String ref = Error.class.getSimpleName();
        if (swagger.getDefinitions() != null && swagger.getDefinitions().containsKey(ref)) {
            // model already registered
            return new RefProperty(ref);
        }

        ModelImpl model = new ModelImpl();
        swagger.addDefinition(ref, model);

        model.setDescription("an error message");

        model.addProperty("statusCode", new IntegerProperty().readOnly().description("http status code"));
        model.addProperty("statusMessage", new StringProperty().readOnly().description("description of the http status code"));
        model.addProperty("requestMethod", new StringProperty().readOnly().description("http request method"));
        model.addProperty("requestUri", new StringProperty().readOnly().description("http request path"));
        model.addProperty("message", new StringProperty().readOnly().description("application message"));

        if (settings.isDev()) {
            // in DEV mode the stacktrace is returned in the error message
            model.addProperty("stacktrace", new StringProperty().readOnly().description("application stacktrace"));
        }

        return new RefProperty(ref);
    }
840132
def create_swagger_json_handler(app, **kwargs):
    

    spec = get_swagger_spec(app)
    _add_blueprint_specs(app, spec)
    spec_dict = spec.swagger_definition(**kwargs)
    encoded_spec = json.dumps(spec_dict).encode("UTF-8")

    async def swagger(request):
        return HTTPResponse(
            body_bytes=encoded_spec,
            headers={
                "Access-Control-Allow-Origin": "*"
            },
            content_type="application/json",
        )

    return swagger
458711
public Swagger2MarkupConfigBuilder withSwaggerMarkupLanguage(MarkupLanguage swaggerMarkupLanguage) {
        Validate.notNull(swaggerMarkupLanguage, "%s must not be null", "swaggerMarkupLanguage");
        config.swaggerMarkupLanguage = swaggerMarkupLanguage;
        return this;
    }
171190
function registerApi(isApp, apiObject) {

  if (isApp) {
    return function (req, res, next) {
      res.__api = apiObject;
      return next();
    };
  };
  
  return function (req, res, next) {
    res.__modelAPI = apiObject;
    return next();
  };
}
127477
public HttpResponseHandler<AmazonServiceException> createErrorResponseHandler(
            JsonErrorResponseMetadata errorResponsMetadata) {
        return getSdkFactory().createErrorResponseHandler(errorUnmarshallers, errorResponsMetadata
                .getCustomErrorCodeFieldName());
    }
382439
def build_swagger12_handler(schema):
    
    if schema:
        return SwaggerHandler(
            op_for_request=schema.validators_for_request,
            handle_request=handle_request,
            handle_response=validate_response,
        )
679851
def _validate_error_response_model(self, paths, mods):
        '''
        
        '''
        for path, ops in paths:
            for opname, opobj in six.iteritems(ops):
                if opname not in _Swagger.SWAGGER_OPERATION_NAMES:
                    continue

                if 'responses' not in opobj:
                    raise ValueError('missing mandatory responses field in path item object')
                for rescode, resobj in six.iteritems(opobj.get('responses')):
                    if not self._is_http_error_rescode(str(rescode)):  # future lint: disable=blacklisted-function
                        continue

                    # only check for response code from 400-599
                    if 'schema' not in resobj:
                        raise ValueError('missing schema field in path {0}, '
                                         'op {1}, response {2}'.format(path, opname, rescode))

                    schemaobj = resobj.get('schema')
                    if '$ref' not in schemaobj:
                        raise ValueError('missing $ref field under schema in '
                                         'path {0}, op {1}, response {2}'.format(path, opname, rescode))
                    schemaobjref = schemaobj.get('$ref', '/')
                    modelname = schemaobjref.split('/')[-1]

                    if modelname not in mods:
                        raise ValueError('model schema {0} reference not found '
                                         'under /definitions'.format(schemaobjref))
                    model = mods.get(modelname)

                    if model.get('type') != 'object':
                        raise ValueError('model schema {0} must be type object'.format(modelname))
                    if 'properties' not in model:
                        raise ValueError('model schema {0} must have properties fields'.format(modelname))

                    modelprops = model.get('properties')
                    if 'errorMessage' not in modelprops:
                        raise ValueError('model schema {0} must have errorMessage as a property to '
                                         'match AWS convention. If pattern is not set, .+ will '
                                         'be used'.format(modelname))
1296884
static Swagger validate( File jsonFile ) throws Exception {

		// Validate with the Swagger parser
		SwaggerDeserializationResult res = new SwaggerParser().readWithInfo( jsonFile.getAbsolutePath(), null, true );
		if( ! res.getMessages().isEmpty()) {
			for( String s : res.getMessages())
				System.out.println( s );

			throw new Exception( "Errors were found in a Swagger definition: " + jsonFile.getAbsolutePath());
		}

		return res.getSwagger();
	}
415470
function validateStructure (apiDefinition) {
  var results = helpers.validateAgainstSchema(helpers.getJSONSchemaValidator(),
                                              swaggerSchema,
                                              apiDefinition.definitionFullyResolved);

  // Make complex JSON Schema validation errors easier to understand (Issue 15)
  results.errors = results.errors.map(function (error) {
    var defType = ['additionalProperties', 'items'].indexOf(error.path[error.path.length - 1]) > -1 ?
          'schema' :
          error.path[error.path.length - 2];

    if (['ANY_OF_MISSING', 'ONE_OF_MISSING'].indexOf(error.code) > -1) {
      switch (defType) {
      case 'parameters':
        defType = 'parameter';
        break;

      case 'responses':
        defType = 'response';
        break;

      case 'schema':
        defType += ' ' + error.path[error.path.length - 1];

        // no default
      }

      error.message = 'Not a valid ' + defType + ' definition';
    }

    return error;
  });

  // Treat invalid/missing references as structural errors
  _.each(apiDefinition.references, function (refDetails, refPtr) {
    var refPath = JsonRefs.pathFromPtr(refPtr);
    var err;

    if (refDetails.missing) {
      err = {
        code: 'UNRESOLVABLE_REFERENCE',
        message: 'Reference could not be resolved: ' + refDetails.uri,
        path: refPath.concat('$ref')
      };

      if (_.has(refDetails, 'error')) {
        err.error = refDetails.error;
      }

      results.errors.push(err);
    } else if (refDetails.type === 'invalid') {
      results.errors.push({
        code: 'INVALID_REFERENCE',
        message: refDetails.error || 'Invalid JSON Reference',
        path: refPath.concat('$ref')
      });
    } else if (_.has(refDetails, 'warning')) {
      // json-refs only creates warnings for JSON References with superfluous properties which will be ignored
      results.warnings.push({
        code: 'EXTRA_REFERENCE_PROPERTIES',
        message: refDetails.warning,
        path: refPath
      });
    }
  });

  return results;
}
852254
def create_swagger_json_handler(app, **kwargs):
    

    spec = getattr(app, SWAGGER_ATTR_NAME, SwaggerSpec())
    _add_blueprint_specs(app, spec)
    spec_dict = spec.swagger_definition(**kwargs)
    encoded_spec = json.dumps(spec_dict).encode("UTF-8")

    def swagger():
        return Response(
            encoded_spec,
            # we allow CORS, so this can be requested at swagger.io
            headers={
                "Access-Control-Allow-Origin": "*"
            },
            content_type="application/json",
        )

    return swagger
890971
public HttpResponseHandler<SdkBaseException> createErrorResponseHandler(
            JsonErrorResponseMetadata errorResponsMetadata) {
        return new ApiGatewayErrorResponseHandler(
                createErrorUnmarshallers(errorResponsMetadata.getErrorShapes().stream()),
                SdkStructuredPlainJsonFactory.JSON_FACTORY);
    }
360657
def error_class_for(status)
      case status
      when 400 then Esi::ApiBadRequestError
      when 401 then Esi::UnauthorizedError
      when 403 then Esi::ApiForbiddenError
      when 404 then Esi::ApiNotFoundError
      when 502 then Esi::TemporaryServerError
      when 503 then Esi::RateLimitError
      else Esi::ApiUnknownError
      end
    end
1071070
protected void registerResponse(Swagger swagger, Operation operation, Return aReturn) {
        Response response = new Response();
        response.setDescription(translate(aReturn.descriptionKey(), aReturn.description()));

        Class<?> resultType = aReturn.onResult();
        if (Exception.class.isAssignableFrom(resultType)) {
            Property errorProperty = registerErrorModel(swagger);
            response.setSchema(errorProperty);
        } else if (Void.class != resultType) {
            // Return type
            if (resultType.isArray()) {
                // ARRAY[]
                Class<?> componentClass = resultType.getComponentType();
                ArrayProperty arrayProperty = new ArrayProperty();
                Property componentProperty = getSwaggerProperty(swagger, componentClass);
                arrayProperty.setItems(componentProperty);
                response.setSchema(arrayProperty);
            } else {
                // Object
                Property returnProperty = getSwaggerProperty(swagger, resultType);
                response.setSchema(returnProperty);
            }
        }

        for (Class<? extends ReturnHeader> returnHeader : aReturn.headers()) {
            Tag headerTag = getModelTag(returnHeader);
            ReturnHeader header = ClassUtil.newInstance(returnHeader);
            Property property = getSwaggerProperty(swagger, header.getHeaderType());
            if (property instanceof ArrayProperty) {
                // FIXME swagger-core has incomplete response header specification methods :(
                ArrayProperty arrayProperty = (ArrayProperty) property;
            }
            property.setName(headerTag.getName());
            property.setDescription(headerTag.getDescription());
            response.addHeader(property.getName(), property);
        }

        operation.response(aReturn.code(), response);
    }
57370
def register_model(cls, model):
        

        rest_name = model.rest_name
        resource_name = model.resource_name

        if rest_name not in cls._model_rest_name_registry:
            cls._model_rest_name_registry[rest_name] = [model]
            cls._model_resource_name_registry[resource_name] = [model]

        elif model not in cls._model_rest_name_registry[rest_name]:
            cls._model_rest_name_registry[rest_name].append(model)
            cls._model_resource_name_registry[resource_name].append(model)
1244982
public static GoCardlessApiException toException(ApiErrorResponse error) {
        switch (error.getType()) {
            case GOCARDLESS:
                return new GoCardlessInternalException(error);
            case INVALID_API_USAGE:
                return new InvalidApiUsageException(error);
            case INVALID_STATE:
                return new InvalidStateException(error);
            case VALIDATION_FAILED:
                return new ValidationFailedException(error);
        }
        throw new IllegalStateException("Unknown error type: " + error.getType());
    }
1201813
public static Builder from(String swaggerString) {
        Validate.notEmpty(swaggerString, "swaggerString must not be null");
        return from(new StringReader(swaggerString));
    }
392023
def _to_swagger(base=None, description=None, resource=None, options=None):
    # type: (Dict[str, str], str, Resource, Dict[str, str]) -> Dict[str, str]
    
    definition = dict_filter(base or {}, options or {})

    if description:
        definition['description'] = description.format(
            name=getmeta(resource).name if resource else "UNKNOWN"
        )

    if resource:
        definition['schema'] = {
            '$ref': '#/definitions/{}'.format(getmeta(resource).resource_name)
        }

    return definition