Apigee API hub enables you to consolidate and organize information about all of the APIs in your company's organization.
Every API type (OpenAPI, GraphQL, Async apis) has a visualizer that takes the raw specification and renders the information, which is easy to understand.
We have built an open source solution which reads the specification, combines that with deployment information from API hub and renders using tools which are already available in the open source community.
This solution is just a sample and can be extended to add other formats or use your own preferred renders.
These are the visualizers we are have implemented:
API Type |
Rendering library |
OpenAPI |
|
GraphQL |
|
Async API |
|
gRPC API |
HTML documentation generated using protoc-gen-doc plugin |
OpenAPI mock service using Prism | |
GraphQL mock service |
Other deployment options for spec renderers are documented in the Registry Experimental Github repository.
To test this setup we will use the registry tool to upload the different types of specifications (OpenAPI, GraphQL and Async API) into the API hub. You can download all the samples from here.
REGISTRY_PROJECT_IDENTIFIER=<API hub GCP Project ID>
registry config configurations create config-$REGISTRY_PROJECT_IDENTIFIER \
--registry.address=apigeeregistry.googleapis.com:443 \
--registry.insecure=0 \
--registry.project=$REGISTRY_PROJECT_IDENTIFIER \
--registry.location=global
registry config set token-source 'gcloud auth print-access-token'
RENDERING_SERVICE=<Cloud Run URL for spec rendering service>
registry apply -f . \
--parent=projects/$REGISTRY_PROJECT_IDENTIFIER/locations/global
registry rpc create-api-deployment \
--api_deployment.display_name=sample \
--api_deployment.endpoint_uri="https://petstore.swagger.io/v2" \
--api_deployment.api_spec_revision="projects/$REGISTRY_PROJECT_IDENTIFIER/locations/global/apis/openapi-sample/versions/v1/specs/petstore.json" \
--api_deployment.external_channel_uri="$RENDERING_SERVICE/render/projects/$REGISTRY_PROJECT_IDENTIFIER/locations/global/apis/openapi-sample/deployments/sample" \
--api_deployment.name=projects/$REGISTRY_PROJECT_IDENTIFIER/locations/global/apis/openapi-sample/deployments/sample \
--api_deployment.name=projects/$REGISTRY_PROJECT_IDENTIFIER/locations/global/apis/openapi-sample/deployments/sample \
--api_deployment_id=sample \
--api_deployment.labels="apihub-gateway=apihub-unmanaged" \
--api_deployment.annotations="apihub-external-channel-name=View Documentation" \
--parent=projects/$REGISTRY_PROJECT_IDENTIFIER/locations/global/apis/openapi-sample
registry rpc create-api-deployment \
--api_deployment.display_name=sample \
--api_deployment.api_spec_revision="projects/$REGISTRY_PROJECT_IDENTIFIER/locations/global/apis/asyncapi-sample/versions/v1/specs/streetlights-mqttyml" \
--api_deployment.external_channel_uri="$RENDERING_SERVICE/render/projects/$REGISTRY_PROJECT_IDENTIFIER/locations/global/apis/asyncapi-sample/deployments/sample" \
--api_deployment.name=projects/$REGISTRY_PROJECT_IDENTIFIER/locations/global/apis/asyncapi-sample/deployments/sample \
--api_deployment_id=sample \
--api_deployment.labels="apihub-gateway=apihub-unmanaged" \
--api_deployment.annotations="apihub-external-channel-name=View Documentation" \
--parent=projects/$REGISTRY_PROJECT_IDENTIFIER/locations/global/apis/asyncapi-sample
registry rpc create-api-deployment \
--api_deployment.display_name=sample \
--api_deployment.api_spec_revision="projects/$REGISTRY_PROJECT_IDENTIFIER/locations/global/apis/graphql-sample/versions/v1/specs/schemagraphql" \
--api_deployment.external_channel_uri="$RENDERING_SERVICE/render/projects/$REGISTRY_PROJECT_IDENTIFIER/locations/global/apis/graphql-sample/deployments/sample" \
--api_deployment.name=projects/$REGISTRY_PROJECT_IDENTIFIER/locations/global/apis/graphql-sample/deployments/sample \
--api_deployment_id=sample \
--api_deployment.endpoint_uri="https://api.spacex.land/graphql" \
--api_deployment.labels="apihub-gateway=apihub-unmanaged" \
--api_deployment.annotations="apihub-external-channel-name=View Documentation" \
--parent=projects/$REGISTRY_PROJECT_IDENTIFIER/locations/global/apis/graphql-sample
registry rpc create-api-deployment \
--api_deployment.display_name=sample \
--api_deployment.api_spec_revision="projects/$REGISTRY_PROJECT_IDENTIFIER/locations/global/apis/grpc-sample/versions/v1/specs/provisioning-serviceproto" \
--api_deployment.external_channel_uri="$RENDERING_SERVICE/render/projects/$REGISTRY_PROJECT_IDENTIFIER/locations/global/apis/grpc-sample/deployments/sample" \
--api_deployment.name=projects/$REGISTRY_PROJECT_IDENTIFIER/locations/global/apis/grpc-sample/deployments/sample \
--api_deployment_id=sample \
--api_deployment.endpoint_uri="https://apigeeregistry.googleapis.com" \
--api_deployment.labels="apihub-gateway=apihub-unmanaged" \
--api_deployment.annotations="apihub-external-channel-name=View Documentation" \
--parent=projects/$REGISTRY_PROJECT_IDENTIFIER/locations/global/apis/grpc-sample