API
  • API Index
  • Batch API
  • Content Negotiation
  • Dynamic Paths
  • Hierarchy API
  • List API
  • Quick Reference
  • Time Series API
  • Views
    • Configuration
  • Overview
  • Application Configuration
  • Documentation Configuration
  • Spec Configuration
    • Features
  • API Testing
  • Asynchronous Processing
  • Cassandra Time-Series Engine
  • Cassandra Integration
  • Default Controller Customisation
  • Documentation
  • Geospatial Filtering
  • Model Documentation
  • PostgreSQL Integration
  • Excel Spreadsheet Format
    • Tutorials
  • Step-by-Step Guide
  • Archetype Setup
  • Logging
  • Prometheus
  • Sentry Logging
    • UI Customisation
  • UI Customisation
  • SASS Build Chain
  • Shared Layout
  • API Documentation
  • Model Documentation
  • Results
  • sapi-nt v current

    Application Configuration

    Sapi-nt applications use an application.yaml(or application.properties) Spring configuration file to set up their app-wide settings and core functionality. This file is located in the src/main/resources directory, where it is automatically discovered by Spring. It contains the standard configuration properties for a Spring Boot web application, as well as options that are specific to sapi-nt and any other Spring-based integrations that are included with it.

    Your application.yaml is packaged into the JAR when the application is built, so you will need to rebuild the JAR for changes to take effect (your IDE will do this automatically).

    Since the application configuration is managed by Spring, you can use standard Spring functionality such as overriding values with command line parameters, and binding values to other properties using the syntax ${property}.

    Spring Documentation

    Configuration

    The names of the configuration properties are given as dot-separated lists of tokens. When written as a .properties file, these full names are used. When written as .yaml file, this notation denotes a nested tree structure. All of the configuration properties that are specific to sapi-nt are prefixed with the sapi-nt token.

    The sapi-nt configs are classified into three broad categories; API, core config and defaults.

    API

    The API configs, prefixed by the sapi-nt.api token, include the descriptive properties of the API itself, as well as some general configuration options.

    Name Meaning Default
    sapi-nt.api.name The name of the API.  
    sapi-nt.api.description A brief description of the API.  
    sapi-nt.api.title A user friendly api title used in the navigation bar of rendered pages.  
    sapi-nt.api.baseURI The root URI where the API will be located. http://localhost/
    sapi-nt.api.comment An additional comment for documentation purposes (e.g. describing the current development status of the API).  
    sapi-nt.api.publisher The name or URL of the API publisher.  
    sapi-nt.api.contactEmail Feedback/help email address monitored by publisher or service provider. info@epimorphics.com
    sapi-nt.api.licenseName Name of the license under which the API is published. Aliased as licenceName.  
    sapi-nt.api.licenseURI URL of the license terms for the API. Aliased as licenceURI.  
    sapi-nt.api.version The version of the API. 0.1

    Deprecated API Properties

    Name Description
    sapi-nt.api.apiName Deprecated - Please use sapi-nt.api.name
    sapi-nt.api.apiDescription Deprecated - Please use sapi-nt.api.description
    sapi-nt.api.pebbleStrict Deprecated - Please use sapi-nt.pebble.strict
    sapi-nt.api.pebbleCache Deprecated - Please use sapi-nt.pebble.cache
    sapi-nt.api.maxAge Deprecated - Please use sapi-nt.config.maxAge
    sapi-nt.api.preferredContentType Deprecated - Please use sapi-nt.config.preferredContentType
    sapi-nt.api.defaultContentType Deprecated - Please use sapi-nt.config.defaultContentType
    sapi-nt.api.itemResultAsArray Deprecated - Please use sapi-nt.config.itemResultAsArray
    sapi-nt.api.jsonItemsNotation Deprecated - Please use sapi-nt.config.jsonItemsNotation
    sapi-nt.api.defaultEndpointName Deprecated - Please use sapi-nt.config.defaultEndpointName
    sapi-nt.api.contextAlias Deprecated - Please use sapi-nt.config.contextAlias
    sapi-nt.api.defaultItemTemplate Deprecated - Please use sapi-nt.config.defaultItemTemplate
    sapi-nt.api.defaultListTemplate Deprecated - Please use sapi-nt.config.defaultListTemplate

    Base URI

    You should configure the base URI of your application (sapi-nt.baseURI) to be the URL where the API is located, including the path. This allows your API to function normally regardless of which domain (eg. localhost or a proxy server) it is accessed from. The base URI should use an appropriate domain and path for the data which the API is responsible for exposing. In particular, item endpoints will use this base URI to locate specific resources in the data store.

    Context Alias (Proxy)

    You should usually only set the sapi-nt.api.contextAlias property if the API is being served by a proxy server. You should set its value to be the path on the proxy server that is identified with the context path of the application (unless the paths are the same, in which case you do not need to set this property). This will ensure that when users view API results in HTML format, the rendered links to other resources will target the correct server-relative path to the resource.

    Core Config

    The general app-wide configs are prefixed with the sapi-nt.config token.

    Name Meaning Default
    sapi-nt.config.loadSpecPath A directory from which spec files will be dynamically loaded. Can be either a file path (eg. /my/project/specs) or a class path(e.g. classpath:endpointSpecs). classpath:endpointSpecs
    sapi-nt.config.docSpecPath A directory from which the documentation spec file and any external HTML files are to be loaded. Can be either a file path(e.g. /my/project/documentation) or a class path(e.g. classpath:documentation).  
    sapi-nt.config.staticResourcesUrlPath A relative URL path from which static resources will be served. The path is relative to the base URI of the API. The static resource files should be stored locally in src/main/resources/public. /public
    sapi-nt.config.checkNonOptionalBindings If true, SPARQL-based list endpoints will issue queries which bind mandatory properties in their inner query. true
    sapi-nt.config.enableSpecMonitoring Toggle live monitoring of the directory specified by loadSpecPath, which updates the application based on changes to configuration files. This only affects applications where loadSpecPath is a file path. false
    sapi-nt.config.resourceAliases A list of resource context aliases that allow serving of static resources from both the classpath and the file system. For each alias it is necessary to set a contextPath to locate the resources and a list of location aliases from which to serve the resources either prefixed with classpath: or file: depending on the location.  
    sapi-nt.config.textSearch.limit The maximum number of results that can be bound by a SPARQL text query clause. Can be overridden by endpoint configurations. Default value is applied by Jena text engine. 10000
    sapi-nt.config.maxAge The maximum age (in seconds) to include in the cache control headers for each response.  
    sapi-nt.config.preferredContentType A content type which has priority over other content types when multiple types are requested.  
    sapi-nt.config.defaultContentType The content type to return from endpoints by default if no specific types were requested by the client. application/json
    sapi-nt.config.preferredLanguage A preferred language, denoted by its BCP47 language tag. If an object has multiple labels the label with prefered language will be rendered in the HTML page if at all present. en
    sapi-nt.config.itemResultAsArray If set to true then an item endpoint returns a singleton array of “items”, if set to false then the item is returned directly as the value of “item”, no array true
    sapi-nt.config.jsonItemsNotation The property name to use to denote the array of results on a response object in JSON format. items
    sapi-nt.config.jsonRenderIdAsString Toggle rendering resources as strings in JSON format. Introduced for sapi2 compatibility. false
    sapi-nt.config.jsonSortArrayValues Toggle rendering array values in alphabetical order in JSON format. Introduced for sapi2 compatibility. false
    sapi-nt.config.defaultEndpointName The name of the default endpoint to be returned if the requested URI does not map to any specific endpoint. If this value is not the name of any endpoint, a 404 response will be returned. deflt
    sapi-nt.config.contextAlias The server-relative path from which API users will access the API, if it differs from the context path of the application.  
    sapi-nt.config.includeResultMetadata Whether to include metadata in JSON, TTL and RDF+XML results. false
    sapi-nt.config.defaultItemTemplate Name of a Pebble template to render for item endpoints if there is none configured.  
    sapi-nt.config.defaultListTemplate Name of a Pebble template to render for list endpoints if there not configured.  
    sapi-nt.config.ui.renderDepth The maximum depth of nested properties to render in HTML results. 2
    sapi-nt.config.ui.suppressLinksTo A list of namespaces to which links are to be suppressed in the UI.  
    sapi-nt.config.sparql.http.maxRetries A maximum number of request retries to a remote sparql data source. 10
    sapi-nt.config.sparql.http.retryInterval A request retry interval(milliseconds) on the remote sparql data source. 100

    Web Config

    Properties in charge of adding predefined controllers to the application context.

    Name Meaning Default
    sapi-nt.web.controller.default.enabled Enables default HTTP request handling for configured API endpoints. false
    sapi-nt.web.controller.default.path The request mapping prefix for the configured API endpoints. ` `
    sapi-nt.web.controller.doc.enabled Enables default HTTP request handling for the configured documentation. false
    sapi-nt.web.controller.doc.path The request mapping prefix for the documentation endpoints. /doc
    sapi-nt.web.controller.batch.enabled Controls whether to respond to batch requests and add them to the queue. Equivalent to sapi-nt.batch.enabled. false
    sapi-nt.web.controller.batch.path The URL path segment that the user will append to an existing endpoint path to make a batch request to that endpoint. Has precedence over sapi-nt.batch.path. /batch
    sapi-nt.web.controller.diagram.enabled Enables default HTTP request handling for model diagrams. false

    Health Config

    Properties in charge of configuring health monitoring components.

    Name Meaning Default
    sapi-nt.health.enabled Determines whether the health monitoring is enabled or not. false
    sapi-nt.health.oom.limit The limit of OutOfMemoryError occurrences allowed during the time period defined by the leakInterval. 3
    sapi-nt.health.oom.leakInterval The interval after which a single OutOfMemoryError is cleared out of the backlog, if present. Value is in minutes. 30

    When the health monitoring is enabled, i.e. the sapi-nt.health.enabled is set to true, then the HealthController will be added to the context exposing one endpoint:

    Path Description
    /health/live Returns 200 if application is healthy and 400 otherwise.

    This endpoint can be utilised by a kubernetes liveness probe if the sapi-nt application is run inside the kubernetes cluster.

    Pebble Config

    Properties in charge of configuring pebble templating engine

    Name Meaning Default
    sapi-nt.pebble.strict If set to true, Pebble will throw an exception if you try to access a variable or attribute that does not exist (or an attribute of a null variable). Otherwise, your non-existing variables/attributes are treated as null. false
    sapi-nt.pebble.cache If true, Pebble templates will be cached after initialisation. Otherwise, they will be recompiled with every invocation. false

    Defaults

    You can set defaults, prefixed with sapi-nt.defaults to define default values for certain spec properties.

    Spec Defaults

    These defaults are applied anywhere that a spec has no value for the corresponding property.

    Name Spec Type Default
    sapi-nt.defaults.spec.property.filterable Property (model) true
    sapi-nt.defaults.spec.property.optional Property (model) false
    sapi-nt.defaults.spec.property.external Property (model) false
    sapi-nt.defaults.spec.property.multi Property (model) false
    sapi-nt.defaults.spec.property.hide Property (model) false
    sapi-nt.defaults.spec.property.unique Property (model) false
    sapi-nt.defaults.spec.endpoint.list.distinct list false
    sapi-nt.defaults.spec.endpoint.list.filterDistinct list true
    sapi-nt.defaults.spec.endpoint.list.unionStyle list false
    sapi-nt.defaults.spec.endpoint.list.softLimit list  
    sapi-nt.defaults.spec.endpoint.item.isDescribe item true
    sapi-nt.defaults.spec.endpoint.item.unionStyle item true

    Note

    If you have configured a default soft limit for list endpoints in this way, you will not be able to override this with an empty or null soft limit in the usual way. However, you can remove the default soft limit from a list endpoint by setting its softLimit value to -1.

    Example

    sapi-nt:
      api:
        apiName: Demo App
        apiDescription: >
          This is a sapi-nt Demo Application. It is mainly used to play around with the features so feel free
          to test it and report any bugs.
        baseURI: http://environment.data.gov.uk/test
        comment: This is a test comment
        publisher: Epimorphics
        licenseName: OGL 3
        licenseURI:  http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/
        maxAge: 10000
        defaultItemTemplate: item
        defaultListTemplate: list
      config:
        loadSpecPath: "classpath:endpointSpecs"
        docSpecPath: "classpath:doc"
        checkNonOptionalBindings: false
        enableSpecMonitoring: false
        contextAliases:
          - contextPath: "/static/csv"
            aliases:
              - "file:/home/user/Documents/static/csv/"
      defaults:
        spec:
          endpoint:
            list:
              unionStyle: true
            item:
              isDescribe: false
          property:
            optional: true
            filterable: false
    

    Profiles

    You should use your application.yaml file to configure the application as it should be in production. If you are creating a base configuration which will be used by other developers, make sure that you set values which will be compatible with all development environments, for example by using a classpath: prefix when specifying resource locations such as loadSpecPath and docSpecPath.

    However, you may need to configure your application specifically for your local environment while developing or testing. You can override any application properties (both sapi-nt and Spring properties) in your local environment by making use of the profiles feature of Spring Boot. This is available by default in all sapi-nt applications.

    You can create a profile-specific configuration file named application-{profileName}.yaml or application-{profileName}.properties and run the application with the active Spring profile set to {profileName}. You can do so by setting the Active Profiles field in your run configuration to {profileName}, or by setting the command line flag: --spring.profiles.active={profileName}.

    Example

    For example, to configure the port on which the server runs in your local environment and enable local spec file monitoring, you could create a file application-developer.yaml with the contents below, and pass the command line flag --spring.profiles.active=developer.

    server:
      port: 9898
    sapi-nt:
      config:
        loadSpecPath: /my/local/project/src/main/resources/endpointSpecs
        enableSpecMonitoring: true
    

    Note

    If you create additional profiles that you wish to use often, make sure to add application-{profileName}.yaml to your .gitignore file so that your profiles do not clash with those of other developers.