Skip to content

Positional %s placeholders in endpoint configuration prevent adding more Skosmos resources #182

Description

@jusa3

agrovoc is hard coded in the skosmos yaml and multiple endpoint paths (for all sources) are currently configured using positional %s placeholders, for example:

  concept_details:
    path: /agrovoc/label?acronym=%s&uri=%s
    responseMapping:
      <<: *term

From https://github.com/ts4nfdi/api-gateway/blob/main/src/main/resources/backend_types/skosmos.yml#L41

This prevents adding more Skosmos sources.

The values for these placeholders are assembled in AbstractEndpointService.getRequestIds() and passed as a String through ApiAccessor.get() to ApiAccessor.constructUrl(), where the final URL is created.

The first argument is typically referred to as the acronym, while the second argument is optionally an encoded URI. Depending on the endpoint, additional values (e.g. pagination) are manually appended to the argument list before calling ApiAccessor.

This causes several issues:

  • The meaning of each %s placeholder is implicit and depends entirely on its position.
  • Adding a new placeholder (e.g. a third %s in the Skosmos model) requires changes in the Java code that builds the argument list (changing multiple method signatures to add a third parameter).
  • Different endpoints require different parameter orders, making the implementation difficult to extend.
  • The current implementation cannot determine whether a placeholder represents an acronym, URI, page number, or another parameter
  • The current implementation only builds one or two parameters by default (acronym and optional encoded URI), additional parameters must be added manually by individual methods (e.g. pagination).

For e.g. replacing positional %s placeholders with named parameters we would need to:

  • change the YAML syntax (%s → {acronym}, {uri}, {page}, etc.).
  • replace constructUrl() with something like UriTemplate or UriComponentsBuilder.
  • replace getRequestIds() so it returns a Map<String, String> instead of a List.
  • update the few places that currently append parameters (page, uri, etc.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions