Skip to content

Commit

Permalink
rename ndc-rest to ndc-http
Browse files Browse the repository at this point in the history
  • Loading branch information
hgiasac committed Nov 11, 2024
1 parent 1b5065d commit fe4c612
Show file tree
Hide file tree
Showing 124 changed files with 2,259 additions and 1,635 deletions.
10 changes: 5 additions & 5 deletions .github/scripts/plugin-manifest.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/bash

export CLI_VERSION=$GITHUB_REF_NAME
export MACOS_AMD64_SHA256=$(sha256sum "_output/ndc-rest-schema-darwin-amd64" | awk '{ print $1 }')
export MACOS_ARM64_SHA256=$(sha256sum "_output/ndc-rest-schema-darwin-arm64" | awk '{ print $1 }')
export LINUX_AMD64_SHA256=$(sha256sum "_output/ndc-rest-schema-linux-amd64" | awk '{ print $1 }')
export LINUX_ARM64_SHA256=$(sha256sum "_output/ndc-rest-schema-linux-arm64" | awk '{ print $1 }')
export WINDOWS_AMD64_SHA256=$(sha256sum "_output/ndc-rest-schema-windows-amd64.exe" | awk '{ print $1 }')
export MACOS_AMD64_SHA256=$(sha256sum "_output/ndc-http-schema-darwin-amd64" | awk '{ print $1 }')
export MACOS_ARM64_SHA256=$(sha256sum "_output/ndc-http-schema-darwin-arm64" | awk '{ print $1 }')
export LINUX_AMD64_SHA256=$(sha256sum "_output/ndc-http-schema-linux-amd64" | awk '{ print $1 }')
export LINUX_ARM64_SHA256=$(sha256sum "_output/ndc-http-schema-linux-arm64" | awk '{ print $1 }')
export WINDOWS_AMD64_SHA256=$(sha256sum "_output/ndc-http-schema-windows-amd64.exe" | awk '{ print $1 }')

envsubst < .github/scripts/plugin-manifest.yaml > release/manifest.yaml
46 changes: 23 additions & 23 deletions .github/scripts/plugin-manifest.yaml
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
name: ndc-rest
name: ndc-http
version: "${CLI_VERSION}"
shortDescription: "CLI plugin for Hasura REST data connector"
homepage: https://github.com/hasura/ndc-rest
shortDescription: "CLI plugin for Hasura HTTP data connector"
homepage: https://github.com/hasura/ndc-http
hidden: true
platforms:
- selector: darwin-arm64
uri: "https://github.com/hasura/ndc-rest/releases/download/${CLI_VERSION}/ndc-rest-schema-darwin-arm64"
uri: "https://github.com/hasura/ndc-http/releases/download/${CLI_VERSION}/ndc-http-schema-darwin-arm64"
sha256: "${MACOS_ARM64_SHA256}"
bin: "ndc-rest-schema"
bin: "ndc-http-schema"
files:
- from: "./ndc-rest-schema-darwin-arm64"
to: "ndc-rest-schema"
- from: "./ndc-http-schema-darwin-arm64"
to: "ndc-http-schema"
- selector: linux-arm64
uri: "https://github.com/hasura/ndc-rest/releases/download/${CLI_VERSION}/ndc-rest-schema-linux-arm64"
uri: "https://github.com/hasura/ndc-http/releases/download/${CLI_VERSION}/ndc-http-schema-linux-arm64"
sha256: "${LINUX_ARM64_SHA256}"
bin: "ndc-rest-schema"
bin: "ndc-http-schema"
files:
- from: "./ndc-rest-schema-linux-arm64"
to: "ndc-rest-schema"
- from: "./ndc-http-schema-linux-arm64"
to: "ndc-http-schema"
- selector: darwin-amd64
uri: "https://github.com/hasura/ndc-rest/releases/download/${CLI_VERSION}/ndc-rest-schema-darwin-amd64"
uri: "https://github.com/hasura/ndc-http/releases/download/${CLI_VERSION}/ndc-http-schema-darwin-amd64"
sha256: "${MACOS_AMD64_SHA256}"
bin: "ndc-rest-schema"
bin: "ndc-http-schema"
files:
- from: "./ndc-rest-schema-darwin-amd64"
to: "ndc-rest-schema"
- from: "./ndc-http-schema-darwin-amd64"
to: "ndc-http-schema"
- selector: windows-amd64
uri: "https://github.com/hasura/ndc-rest/releases/download/${CLI_VERSION}/ndc-rest-schema-windows-amd64.exe"
uri: "https://github.com/hasura/ndc-http/releases/download/${CLI_VERSION}/ndc-http-schema-windows-amd64.exe"
sha256: "${WINDOWS_AMD64_SHA256}"
bin: "ndc-rest-schema.exe"
bin: "ndc-http-schema.exe"
files:
- from: "./ndc-rest-schema-windows-amd64.exe"
to: "ndc-rest-schema.exe"
- from: "./ndc-http-schema-windows-amd64.exe"
to: "ndc-http-schema.exe"
- selector: linux-amd64
uri: "https://github.com/hasura/ndc-rest/releases/download/${CLI_VERSION}/ndc-rest-schema-linux-amd64"
uri: "https://github.com/hasura/ndc-http/releases/download/${CLI_VERSION}/ndc-http-schema-linux-amd64"
sha256: "${LINUX_AMD64_SHA256}"
bin: "ndc-rest-schema"
bin: "ndc-http-schema"
files:
- from: "./ndc-rest-schema-linux-amd64"
to: "ndc-rest-schema"
- from: "./ndc-http-schema-linux-amd64"
to: "ndc-http-schema"
2 changes: 1 addition & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- name: Format
run: |
diff -u <(echo -n) <(gofmt -d -s .)
cd ndc-rest-schema && diff -u <(echo -n) <(gofmt -d -s .)
cd ndc-http-schema && diff -u <(echo -n) <(gofmt -d -s .)
- name: golangci-lint ${{ matrix.modules }}
uses: golangci/golangci-lint-action@v6
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ on:

env:
DOCKER_REGISTRY: ghcr.io
DOCKER_IMAGE_NAME: hasura/ndc-rest
DOCKER_IMAGE_NAME: hasura/ndc-http

jobs:
tests:
uses: ./.github/workflows/test.yaml

release-image:
name: Release ndc-rest image
name: Release ndc-http image
runs-on: ubuntu-latest
needs: [tests]
steps:
Expand Down
6 changes: 0 additions & 6 deletions .vscode/settings.json

This file was deleted.

2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
FROM golang:1.23 AS builder

WORKDIR /app
COPY ndc-rest-schema ./ndc-rest-schema
COPY ndc-http-schema ./ndc-http-schema
COPY go.mod go.sum go.work ./
RUN go mod download
COPY . .
Expand Down
24 changes: 12 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ OUTPUT_DIR := _output
.PHONY: format
format:
gofmt -w -s .
cd ndc-rest-schema && gofmt -w -s .
cd ndc-http-schema && gofmt -w -s .

.PHONY: test
test:
go test -v -race -timeout 3m ./...
cd ndc-rest-schema && go test -v -race -timeout 3m ./...
cd ndc-http-schema && go test -v -race -timeout 3m ./...

# Install golangci-lint tool to run lint locally
# https://golangci-lint.run/usage/install
.PHONY: lint
lint:
golangci-lint run --fix
cd ndc-rest-schema && golangci-lint run --fix
cd ndc-http-schema && golangci-lint run --fix

# clean the output directory
.PHONY: clean
Expand All @@ -26,30 +26,30 @@ clean:
.PHONY: go-tidy
go-tidy:
go mod tidy
cd ndc-rest-schema && go mod tidy
cd ndc-http-schema && go mod tidy

.PHONY: build-jsonschema
build-jsonschema:
cd ./ndc-rest-schema/jsonschema && go run .
cd ./ndc-http-schema/jsonschema && go run .

# build the ndc-rest-schema for all given platform/arch
# build the ndc-http-schema for all given platform/arch
.PHONY: build-cli
build-cli:
go build -o _output/ndc-rest-schema ./ndc-rest-schema
go build -o _output/ndc-http-schema ./ndc-http-schema

.PHONY: ci-build-cli
ci-build-cli: export CGO_ENABLED=0
ci-build-cli: clean
cd ./ndc-rest-schema && \
cd ./ndc-http-schema && \
go get github.com/mitchellh/gox && \
go run github.com/mitchellh/gox -ldflags '-X github.com/hasura/ndc-rest/ndc-rest-schema/version.BuildVersion=$(VERSION) -s -w -extldflags "-static"' \
go run github.com/mitchellh/gox -ldflags '-X github.com/hasura/ndc-http/ndc-http-schema/version.BuildVersion=$(VERSION) -s -w -extldflags "-static"' \
-osarch="linux/amd64 darwin/amd64 windows/amd64 darwin/arm64 linux/arm64" \
-output="../$(OUTPUT_DIR)/ndc-rest-schema-{{.OS}}-{{.Arch}}" \
-output="../$(OUTPUT_DIR)/ndc-http-schema-{{.OS}}-{{.Arch}}" \
.

.PHONY: generate-test-config
generate-test-config:
go run ./ndc-rest-schema update -d ./tests/configuration
go run ./ndc-http-schema update -d ./tests/configuration

.PHONY: start-ddn
start-ddn:
Expand All @@ -61,7 +61,7 @@ stop-ddn:

.PHONY: build-supergraph-test
build-supergraph-test:
docker compose up -d --build ndc-rest
docker compose up -d --build ndc-http
cd tests/engine && \
ddn connector-link update myapi --add-all-resources --subgraph ./app/subgraph.yaml && \
ddn supergraph build local
Expand Down
55 changes: 28 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# REST Connector
# HTTP Connector

REST Connector allows you to quickly convert REST APIs to NDC schema and proxy requests from GraphQL Engine v3 to remote services.
HTTP Connector allows you to quickly convert HTTP APIs to NDC schema and proxy requests from GraphQL Engine v3 to remote services.
The connector can automatically transform OpenAPI 2.0 and 3.0 definitions to NDC schema.

![REST connector](./assets/rest_connector.png)
![HTTP connector](./assets/rest_connector.png)

> [!NOTE]
> REST connector is configuration-based HTTP engine and isn't limited to the OpenAPI specs only. Use [OpenAPI Connector](https://hasura.io/docs/3.0/connectors/external-apis/open-api) if you want to take more control of OpenAPI via code generation.
> HTTP connector is configuration-based HTTP engine and isn't limited to the OpenAPI specs only. Use [OpenAPI Connector](https://hasura.io/docs/3.0/connectors/external-apis/open-api) if you want to take more control of OpenAPI via code generation.
## Features

- [No code. Configuration based](#configuration).
- Composable.
- Composable API collections.
- [Supported many API specifications](#supported-specs).
- [Supported authentication](#authentication).
- [Supported headers forwarding](#header-forwarding).
Expand All @@ -34,6 +34,7 @@ The connector can automatically transform OpenAPI 2.0 and 3.0 definitions to NDC
- `application/x-www-form-urlencoded`
- `application/octet-stream`
- `multipart/form-data`
- `application/x-ndjson`
- `text/*`
- Upload file content types, e.g.`image/*` from `base64` arguments.

Expand All @@ -47,8 +48,8 @@ go run ./server serve --configuration ./connector/testdata/jsonplaceholder

## Documentation

- [NDC REST schema](./ndc-rest-schema)
- [Recipes](https://github.com/hasura/ndc-rest-recipes/tree/main): You can find or request pre-built configuration recipes of popular API services here.
- [NDC HTTP schema](./ndc-http-schema)
- [Recipes](https://github.com/hasura/ndc-http-recipes/tree/main): You can find or request pre-built configuration recipes of popular API services here.

## Configuration

Expand All @@ -66,7 +67,7 @@ files:
spec: ndc
```
The config of each element follows the [config schema](https://github.com/hasura/ndc-rest/ndc-rest-schema/blob/main/config.example.yaml) of `ndc-rest-schema`.
The config of each element follows the [config schema](https://github.com/hasura/ndc-http/ndc-http-schema/blob/main/config.example.yaml) of `ndc-http-schema`.

You can add many API documentation files into the same connector.

Expand All @@ -77,20 +78,20 @@ You can add many API documentation files into the same connector.

#### OpenAPI

REST connector supports both OpenAPI 2 and 3 specifications.
HTTP connector supports both OpenAPI 2 and 3 specifications.

- `oas3`: OpenAPI 3.0/3.1.
- `oas2`: OpenAPI 2.0.

#### REST schema
#### HTTP schema

Enum: `ndc`
Enum: `http`

REST schema is the native configuration schema which other specs will be converted to behind the scene. The schema extends the NDC Specification with REST configuration and can be converted from other specs by the [NDC REST schema CLI](./ndc-rest-schema).
HTTP schema is the native configuration schema which other specs will be converted to behind the scene. The schema extends the NDC Specification with HTTP configuration and can be converted from other specs by the [NDC HTTP schema CLI](./ndc-http-schema).

### Authentication

The current version supports API key and Auth token authentication schemes. The configuration is inspired from `securitySchemes` [with env variables](https://github.com/hasura/ndc-rest/ndc-rest-schema#authentication). The connector supports the following authentication strategies:
The current version supports API key and Auth token authentication schemes. The configuration is inspired from `securitySchemes` [with env variables](https://github.com/hasura/ndc-http/ndc-http-schema#authentication). The connector supports the following authentication strategies:

- API Key
- Bearer Auth
Expand Down Expand Up @@ -152,7 +153,7 @@ files:

### JSON Patch

You can add JSON patches to extend API documentation files. REST connector supports `merge` and `json6902` strategies. JSON patches can be applied before or after the conversion from OpenAPI to REST schema configuration. It will be useful if you need to extend or fix some fields in the API documentation such as server URL.
You can add JSON patches to extend API documentation files. HTTP connector supports `merge` and `json6902` strategies. JSON patches can be applied before or after the conversion from OpenAPI to HTTP schema configuration. It will be useful if you need to extend or fix some fields in the API documentation such as server URL.

```yaml
files:
Expand All @@ -166,7 +167,7 @@ files:
strategy: json6902
```

See [the example](./ndc-rest-schema/command/testdata/patch) for more context.
See [the example](./ndc-http-schema/command/testdata/patch) for more context.

## Distributed execution

Expand Down Expand Up @@ -215,11 +216,11 @@ files:
"functions": [
{
"arguments": {
"restOptions": {
"httpOptions": {
"type": {
"type": "nullable",
"underlying_type": {
"name": "RestSingleOptions",
"name": "HttpSingleOptions",
"type": "named"
}
}
Expand All @@ -236,11 +237,11 @@ files:
},
{
"arguments": {
"restOptions": {
"httpOptions": {
"type": {
"type": "nullable",
"underlying_type": {
"name": "RestDistributedOptions",
"name": "HttpDistributedOptions",
"type": "named"
}
}
Expand All @@ -254,8 +255,8 @@ files:
}
],
"object_types": {
"RestDistributedOptions": {
"description": "Distributed execution options for REST requests to multiple servers",
"HttpDistributedOptions": {
"description": "Distributed execution options for HTTP requests to multiple servers",
"fields": {
"parallel": {
"description": "Execute requests to remote servers in parallel",
Expand All @@ -273,7 +274,7 @@ files:
"type": "nullable",
"underlying_type": {
"element_type": {
"name": "RestServerId",
"name": "HttpServerId",
"type": "named"
},
"type": "array"
Expand All @@ -282,16 +283,16 @@ files:
}
}
},
"RestSingleOptions": {
"description": "Execution options for REST requests to a single server",
"HttpSingleOptions": {
"description": "Execution options for HTTP requests to a single server",
"fields": {
"servers": {
"description": "Specify remote servers to receive the request. If there are many server IDs the server is selected randomly",
"type": {
"type": "nullable",
"underlying_type": {
"element_type": {
"name": "RestServerId",
"name": "HttpServerId",
"type": "named"
},
"type": "array"
Expand All @@ -306,8 +307,8 @@ files:

</details>

`RestSingleOptions` object type is added to existing operations (findPets). API consumers can specify the server to be executed. If you want to execute all remote servers in sequence or parallel, `findPetsDistributed` function should be used.
`HttpSingleOptions` object type is added to existing operations (findPets). API consumers can specify the server to be executed. If you want to execute all remote servers in sequence or parallel, `findPetsDistributed` function should be used.

## License

REST Connector is available under the [Apache License 2.0](./LICENSE).
HTTP Connector is available under the [Apache License 2.0](./LICENSE).
8 changes: 4 additions & 4 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ All reports are thoroughly investigated by a set of community volunteers.

### When Should I Report a Vulnerability?

- You think you have discovered a potential security vulnerability in the NDC Go SDK or related components.
- You are unsure how a vulnerability affects the SDK.
- You think you discovered a vulnerability in another project that SDK depends on (e.g. Docker, etc).
- You want to report any other security risk that could potentially harm SDK users.
- You think you have discovered a potential security vulnerability in the HTTP connector or related components.
- You are unsure how a vulnerability affects the connector.
- You think you discovered a vulnerability in another project that connector depends on (e.g. Docker, etc).
- You want to report any other security risk that could potentially harm connector users.

### When Should I NOT Report a Vulnerability?

Expand Down
2 changes: 1 addition & 1 deletion compose.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include:
- tests/engine/compose.yaml
services:
ndc-rest:
ndc-http:
build:
context: .
ports:
Expand Down
Loading

0 comments on commit fe4c612

Please sign in to comment.