How to Add API Docs
Software Catalog in Harness IDP provides a comprehensive framework for defining and managing software entities, including APIs. Here’s a guideline to add API specifications, based on the Backstage descriptor format:
The type of API specs could be added in IDP.
-
openapi - An API definition in YAML or JSON format based on the OpenAPI version 2 or version 3 spec.
-
asyncapi - An API definition based on the AsyncAPI specification.
-
graphql - An API definition based on GraphQL schemas for consuming GraphQL based APIs.
-
grpc - An API definition based on Protocol Buffers to use with gRPC.
More details on descriptor format for API's could be found below in the references.
Example for different use cases
Note that to be able to read from targets that are outside the normal integration points such as github.com
, you'll need to explicitly allow it by adding an entry in the URL Allow List under Admin
Import API spec for all API defined in openapi spec
- IDP 2.0 (New)
- IDP 1.0
apiVersion: harness.io/v1
kind: API
type: openapi
identifier: cenextgen
name: cenextgen
owner: johndoe
spec:
lifecycle: production
definition:
$text: https://github.com/OAI/OpenAPI-Specification/blob/main/examples/v2.0/json/api-with-examples.json
metadata:
description: The official CE NEXTGEN service REST APIs
apiVersion: backstage.io/v1alpha1
kind: API
metadata:
name: ce-nextgen
description: The official CE NEXTGEN service REST APIs
spec:
type: openapi
lifecycle: production
owner: johndoe
definition:
$text: https://github.com/OAI/OpenAPI-Specification/blob/main/examples/v2.0/json/api-with-examples.json
In the above example we import all the API specs in json
format as a $text
embedding, and it's a suggested hack to import multiple APIs in openapi format.
The above-mentioned catalog-info.yaml
when registered in the catalog would display all the APIs in the following format.
Import API spec for a single API defined in openapi spec in swaggger
- IDP 2.0 (New)
- IDP 1.0
apiVersion: harness.io/v1
kind: API
type: openapi
identifier: petstore
name: petstore
owner: Harness_Partners
spec:
lifecycle: dev
definition:
$text: ./petstore.oas.yaml
metadata:
description: The petstore API
links:
- url: https://github.com/swagger-api/swagger-petstore
title: GitHub Repo
icon: github
- url: https://github.com/swagger-api/swagger-petstore/blob/master/src/main/resources/openapi.yaml
title: API Spec
icon: code
tags:
- store
- rest
apiVersion: backstage.io/v1alpha1
kind: API
metadata:
name: petstore
description: The petstore API
tags:
- store
- rest
links:
- url: https://github.com/swagger-api/swagger-petstore
title: GitHub Repo
icon: github
- url: https://github.com/swagger-api/swagger-petstore/blob/master/src/main/resources/openapi.yaml
title: API Spec
icon: code
spec:
type: openapi
lifecycle: dev
owner: Harness_Partners
definition:
$text: ./petstore.oas.yaml
The above-mentioned catalog-info.yaml
when registered in the catalog would display all the APIs in the following format.
Define API spec for a single API openapi format and import the same
- IDP 2.0 (New)
- IDP 1.0
apiVersion: harness.io/v1
kind: API
type: openapi
identifier: artistapi
name: artistapi
owner: artist-relations-team
spec:
lifecycle: production
definition: |
openapi: "3.0.0"
info:
version: 1.0.0
title: Artist API
license:
name: MIT
servers:
- url: http://artist.spotify.net/v1
paths:
/artists:
get:
summary: List all artists
...
metadata:
description: Retrieve artist details
apiVersion: backstage.io/v1alpha1
kind: API
metadata:
name: artist-api
description: Retrieve artist details
spec:
type: openapi
lifecycle: production
owner: artist-relations-team
system: artist-engagement-portal
definition: |
openapi: "3.0.0"
info:
version: 1.0.0
title: Artist API
license:
name: MIT
servers:
- url: http://artist.spotify.net/v1
paths:
/artists:
get:
summary: List all artists
...
The above-mentioned catalog-info.yaml
when registered in the catalog would display all the APIs in the following format.
Creating an API entity
- IDP 2.0 (New)
- IDP 1.0
There are two ways to add and create a new API entity in your catalog:
- Create an entity via the Harness IDP UI: Use the Harness UI to create entities directly—no YAML required. This method offers a streamlined, code-free experience for adding entities.
- Create an entity using your catalog YAML: You can still create entities using your existing catalog YAML files. Harness will automatically convert legacy Backstage YAML into the new Harness Catalog Entity Model and register the corresponding entity.
Steps to add an API entity
- Save the YAML, created following the steps above, in your git repository.
- Follow the steps mentioned to register a software component, to add your API docs to IDP.
Descriptor File Structure
File Naming
: Typically namedcatalog-info.yaml
oridp.yaml
.Format
: YAMLSections
: Envelope, Metadata, API Specification, Relations, Status.
Defining an API Entity
- IDP 2.0 (New)
- IDP 1.0
You can refer to the entity definition format here. Here's the common envelope:
apiVersion
: With IDP 2.0, we've introduced a Harness-native entity schema. As part of this change, all entities now use an apiVersion prefixed withharness.io/
.kind
: The kind field defines the high-level type of entity being described in the YAML file. For API,kind
isAPI
.identifier
: Theidentifier
field is a unique, machine-readable reference for the entity. It serves as the primary key for identifying and interacting with the entity.name
: Thename
field represents the display name of the entity shown in the UI.type
: Thetype
field represents the type of entity (e.g., website, service, library, API, etc). The kind and type fields together define entity behavior and should always appear together.projectIdentifier
: In IDP 2.0, legacy System entities are now mapped to Harness Projects. Thus theprojectIdentifier
field indicates which project the entity belongs to.orgIdentifier
: In IDP 2.0, legacy Domain entities are now mapped to Harness Orgs. Thus the fieldorgIdentifier
indicates which Org the entity belongs to.owner
: Theowner
field indicates the owner of that entity and maps to Harness Users or User Groups depending on the scope.metadata
: A container for auxiliary data that is not part of the entity’s specification. Additional metadata helps enhance platform-level processing or categorizationspec
: Defines the actual specification data that describes the entity. This is the core configuration and varies depending on the kind.
apiVersion
: Specify the API version, e.g.,backstage.io/v1alpha1
.kind
: This should be API.metadata
: Includes name, description, labels, and annotations.name
: Unique identifier for the API.description
: Brief overview of the API.labels/annotations
: Key-value pairs for additional metadata.
API Specification
- IDP 2.0 (New)
- IDP 1.0
Kind: API
An API describes an interface that can be exposed by a component. APIs can be defined using formats such as OpenAPI, AsyncAPI, GraphQL, gRPC, or others.
Entity Structure
All the fields mentioned below are the mandatory parameters required to define an API:
Field | Value |
---|---|
apiVersion | harness.io/v1 |
kind | API |
type | You can find out more about the type key here. |
spec.lifecycle | You can find out more about the lifecycle key here. |
spec.definition | You can find out more about the definition key here. |
type
Definition
The type of the API
definition as a string (e.g., openapi
):
openapi
– A definition in YAML or JSON based on OpenAPI v2 or v3.asyncapi
– A definition based on the AsyncAPI specification.graphql
– A definition using GraphQL schemas.grpc
– A definition based on Protocol Buffers for use with gRPC.
Example YAML
apiVersion: harness.io/v1
kind: API
type: openapi
identifier: petstore
name: petstore
owner: Harness_Partners
spec:
lifecycle: dev
definition:
$text: ./petstore.oas.yaml
metadata:
description: The petstore API
links:
- url: https://github.com/swagger-api/swagger-petstore
title: GitHub Repo
icon: github
- url: https://github.com/swagger-api/swagger-petstore/blob/master/src/main/resources/openapi.yaml
title: API Spec
icon: code
tags:
- store
- rest
spec
: Contains the actual API specification details.type
: The type of API (e.g., openapi, grpc), the current set of well-known and supported values for this field is:
openapi - An API definition in YAML or JSON format based on the OpenAPI version 2 or version 3 spec.
asyncapi - An API definition based on the AsyncAPI specification.
graphql - An API definition based on GraphQL schemas for consuming GraphQL based APIs.
grpc - An API definition based on Protocol Buffers to use with gRPC.
lifecycle
: Stage of the API lifecycle (e.g., production, experimental).owner
: Team or individual responsible for the API.definition
: Location of the API definition file (e.g., a URL to a Swagger file).
Substitutions in Descriptor
- Supports
$text
,$json
,$yaml
for embedding external content. - Useful for loading API definitions from external sources.
Example
- IDP 2.0 (New)
- IDP 1.0
apiVersion: harness.io/v1
kind: API
type: openapi
identifier: petstore
name: petstore
owner: Harness_Partners
spec:
lifecycle: dev
definition:
$text: ./petstore.oas.yaml
metadata:
description: The petstore API
links:
- url: https://github.com/swagger-api/swagger-petstore
title: GitHub Repo
icon: github
- url: https://github.com/swagger-api/swagger-petstore/blob/master/src/main/resources/openapi.yaml
title: API Spec
icon: code
tags:
- store
- rest
apiVersion: backstage.io/v1alpha1
kind: API
metadata:
name: petstore
description: The petstore API
tags:
- store
- rest
links:
- url: https://github.com/swagger-api/swagger-petstore
title: GitHub Repo
icon: github
- url: https://github.com/swagger-api/swagger-petstore/blob/master/src/main/resources/openapi.yaml
title: API Spec
icon: code
spec:
type: openapi
lifecycle: dev
owner: Harness_Partners
definition:
$text: ./petstore.oas.yaml
gRPC Docs
You can render gRPC documentation by using the protoc-gen-doc plugin, which contains ApiDefinitionWidgets
for grpc-docsto enable Swagger UI for gRPC APIs.
JSON Format
You can render gRPC documentation when the type
is set to grpc-doc
or grpc
and the definition
is provided in JSON format.
Type: grpc
- IDP 2.0 (New)
- IDP 1.0
##Example
apiVersion: harness.io/v1
kind: API
type: grpc
identifier: grpcdocstest1
name: grpcdocstest1
owner: group:engineering
spec:
lifecycle: production
definition:
$text: https://github.com/pseudomuto/protoc-gen-doc/blob/master/examples/doc/example.json
##Example
apiVersion: backstage.io/v1alpha1
kind: API
metadata:
name: grpc-docs-test-1
spec:
type: grpc
lifecycle: production
owner: group:engineering
definition:
$text: https://github.com/pseudomuto/protoc-gen-doc/blob/master/examples/doc/example.json
Rendered Output for JSON Format
Type: grpc-docs
- IDP 2.0 (New)
- IDP 1.0
apiVersion: harness.io/v1
kind: API
type: grpc-docs
identifier: grpcdocstest
name: grpcdocstest
owner: group:engineering
spec:
lifecycle: production
definition:
$text: https://github.com/pseudomuto/protoc-gen-doc/blob/master/examples/doc/example.json
apiVersion: backstage.io/v1alpha1
kind: API
metadata:
name: grpc-docs-test
spec:
type: grpc-docs
lifecycle: production
owner: group:engineering
definition:
$text: https://github.com/pseudomuto/protoc-gen-doc/blob/master/examples/doc/example.json
Rendered Output for JSON Format
proto file Format
- IDP 2.0 (New)
- IDP 1.0
## Example
apiVersion: harness.io/v1
kind: API
type: grpc
identifier: helloworldunaryapi
name: helloworldunaryapi
owner: zalopay-oss
spec:
lifecycle: production
files:
- file_name: helloworld.proto
file_path: examples/unary/helloworld.proto
url: https://github.com/zalopay-oss/backstage-grpc-playground/blob/main/examples/unary/helloworld.proto
definition:
$text: https://github.com/zalopay-oss/backstage-grpc-playground/blob/main/examples/unary/helloworld.proto
targets:
dev:
host: 0.0.0.0
port: 8084
metadata:
description: helloworld unary gRPC
## Example
apiVersion: backstage.io/v1alpha1
kind: API
metadata:
name: helloworld-unary-api
description: helloworld unary gRPC
spec:
type: grpc
lifecycle: production
owner: zalopay-oss
definition:
$text: https://github.com/zalopay-oss/backstage-grpc-playground/blob/main/examples/unary/helloworld.proto
files:
- file_name: helloworld.proto
file_path: examples/unary/helloworld.proto
url: https://github.com/zalopay-oss/backstage-grpc-playground/blob/main/examples/unary/helloworld.proto
targets:
dev:
host: 0.0.0.0
port: 8084