def validate_spec_url(spec_url): """Validates a Swagger 2.0 API Specification at the given URL. :param spec_url: the URL of the service's swagger spec. :returns: The resolver (with cached remote refs) used during validation :rtype: :class:`jsonschema.RefResolver` :raises: :py:class:`swagger_spec_validator.SwaggerValidationError` """ log.info('Validating %s', spec_url) return validate_spec(read_url(spec_url), spec_url)
def validate_spec_url(spec_url): """Validates a Swagger spec given its URL. :param spec_url: For Swagger 1.2, this is the URL to the resource listing in api-docs. For Swagger 2.0, this is the URL to swagger.json in api-docs. If given as `file://` this must be an absolute url for cross-refs to work correctly. """ spec_json = read_url(spec_url) validator = get_validator(spec_json, spec_url) validator.validate_spec(spec_json, spec_url)
def validate_spec_url(spec_url): """Validates a Swagger spec given its URL. :param spec_url: For Swagger 1.2, this is the URL to the resource listing in api-docs. For Swagger 2.0, this is the URL to swagger.json in api-docs. If given as ``file://``, this must be an absolute url for cross-refs to work correctly. """ spec_json = read_url(spec_url) validator = get_validator(spec_json, spec_url) validator.validate_spec(spec_json, spec_url)
def validate_spec_url(url): """Simple utility function to perform recursive validation of a Resource Listing and all associated API Declarations. This is trivial wrapper function around :py:func:`swagger_spec_validator.validate_resource_listing` and :py:func:`swagger_spec_validator.validate_api_declaration`. You are encouraged to write your own version of this if required. :param url: the URL of the Resource Listing. :returns: `None` in case of success, otherwise raises an exception. :raises: :py:class:`swagger_spec_validator.SwaggerValidationError` """ log.info('Validating %s', url) validate_spec(read_url(url), url)
def validate_spec(resource_listing, url): """ Validates the resource listing, fetches the api declarations and consequently validates them as well. :type resource_listing: dict :param url: url serving the resource listing; needed to resolve api declaration path. :type url: string :returns: `None` in case of success, otherwise raises an exception. :raises: :py:class:`swagger_spec_validator.SwaggerValidationError` """ validate_resource_listing(resource_listing) for api in resource_listing['apis']: path = get_resource_path(url, api['path']) log.info('Validating %s', path) validate_api_declaration(read_url(path))