{{/* Apache Polaris custom redoc shortcode that takes just the file of the OpenAPI spec YAML and loads either the in-development version from the local checkout or a released version from the corresponding Git tag. This is a copy of the Docsy redoc shortcode (v0.14.3), except the URL resolution block is replaced with a Polaris-specific partial that resolves the spec to the correct raw GitHub URL. Copied from Docsy: https://github.com/google/docsy/blob/v0.14.3/layouts/_shortcodes/redoc.html */}} {{- $spec := .Get 0 -}} {{- $otheroptions := .Get 1 -}} {{- $url := partial "rawGithubPolarisUrl.html" (dict "page" . "path" (printf "spec/%s" $spec)) -}} {{- /* Publish the spec with the site, since the ASF CSP blocks fetching it from raw.githubusercontent.com in the browser. In-dev pages use the spec from the local checkout (`assets/polaris-spec` is a symlink to `spec/`), so the result always matches the commit being built. Released pages fetch the spec from the release tag. The build fails if the spec cannot be found. Spec URLs follow the pattern: https://polaris.apache.org/api-specs/{gitRef}/{spec}, e.g. https://polaris.apache.org/api-specs/apache-polaris-1.9.0/polaris-management-service.yml */ -}} {{- $gitRef := partial "polarisGitRef.html" . -}} {{- $specResource := "" -}} {{- if $gitRef.isReleased -}} {{- $specResource = resources.GetRemote $url -}} {{- else -}} {{- $specResource = resources.Get (printf "polaris-spec/%s" $spec) -}} {{- end -}} {{- if not $specResource -}} {{- errorf "Cannot find API spec %s" $url -}} {{- end -}} {{- $specUrl := (resources.FromString (printf "api-specs/%s/%s" $gitRef.ref (path.Base $spec)) $specResource.Content).RelPermalink -}}