Class OpenapiContractRegistry

java.lang.Object
ch.nexsol.gateway.validation.OpenapiContractRegistry

public class OpenapiContractRegistry extends Object
Reads the OpenAPI contracts the filter validates against, and keeps each one for as long as the gateway runs.

Reading and parsing a document blocks, so it happens on the bounded elastic scheduler and only once per location: the first request through a route pays for it, every later one gets the parsed contract straight away. A load that failed is not remembered, so a contract that became reachable again is picked up by the next request rather than needing a restart.

  • Constructor Details

    • OpenapiContractRegistry

      public OpenapiContractRegistry(org.springframework.core.io.ResourceLoader resourceLoader)
      Creates the registry.
      Parameters:
      resourceLoader - the loader used to reach a contract that is not addressed by an http(s) URL
  • Method Details

    • contract

      public reactor.core.publisher.Mono<OpenapiContract> contract(String location)
      Returns the contract at the given location, reading it on first use.
      Parameters:
      location - the contract location: an http(s) URL, or anything the resource loader understands such as classpath: or file:
      Returns:
      a mono emitting the parsed contract, failing with OpenapiContractException when it cannot be read