diff --git a/.github/scripts/plugin-manifest.sh b/.github/scripts/plugin-manifest.sh index 0af1c85..a27f5ac 100755 --- a/.github/scripts/plugin-manifest.sh +++ b/.github/scripts/plugin-manifest.sh @@ -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 \ No newline at end of file diff --git a/.github/scripts/plugin-manifest.yaml b/.github/scripts/plugin-manifest.yaml index fa63121..cff7046 100644 --- a/.github/scripts/plugin-manifest.yaml +++ b/.github/scripts/plugin-manifest.yaml @@ -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" diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 0c283aa..f693422 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -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: diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 07ace15..7e54a4e 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -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: diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 38cd3d0..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "yaml.schemas": { - "file:///home/hgiasac/.vscode/extensions/docsmsft.docs-yaml-1.0.4/dist/toc.schema.json": "/toc\\.yml/i", - "file:///home/hgiasac/projects/hasura/src/ndc-rest/ndc-rest-schema/jsonschema/configuration.schema.json": "file:///home/hgiasac/projects/hasura/src/ndc-rest/ndc-rest-schema/command/testdata/auth/config.yaml" - } -} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index d2452b2..b0c70b7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 . . diff --git a/Makefile b/Makefile index c193715..cd05113 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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: @@ -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 diff --git a/README.md b/README.md index 984ae8c..7dbe61e 100644 --- a/README.md +++ b/README.md @@ -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). @@ -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. @@ -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 @@ -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. @@ -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 @@ -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: @@ -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 @@ -215,11 +216,11 @@ files: "functions": [ { "arguments": { - "restOptions": { + "httpOptions": { "type": { "type": "nullable", "underlying_type": { - "name": "RestSingleOptions", + "name": "HttpSingleOptions", "type": "named" } } @@ -236,11 +237,11 @@ files: }, { "arguments": { - "restOptions": { + "httpOptions": { "type": { "type": "nullable", "underlying_type": { - "name": "RestDistributedOptions", + "name": "HttpDistributedOptions", "type": "named" } } @@ -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", @@ -273,7 +274,7 @@ files: "type": "nullable", "underlying_type": { "element_type": { - "name": "RestServerId", + "name": "HttpServerId", "type": "named" }, "type": "array" @@ -282,8 +283,8 @@ 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", @@ -291,7 +292,7 @@ files: "type": "nullable", "underlying_type": { "element_type": { - "name": "RestServerId", + "name": "HttpServerId", "type": "named" }, "type": "array" @@ -306,8 +307,8 @@ files: -`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). diff --git a/SECURITY.md b/SECURITY.md index f21d6b1..340e9c6 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -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? diff --git a/compose.yaml b/compose.yaml index 6096e70..dd29402 100644 --- a/compose.yaml +++ b/compose.yaml @@ -1,7 +1,7 @@ include: - tests/engine/compose.yaml services: - ndc-rest: + ndc-http: build: context: . ports: diff --git a/connector-definition/.hasura-connector/connector-metadata.yaml b/connector-definition/.hasura-connector/connector-metadata.yaml index 58deba9..63375ab 100644 --- a/connector-definition/.hasura-connector/connector-metadata.yaml +++ b/connector-definition/.hasura-connector/connector-metadata.yaml @@ -1,11 +1,11 @@ packagingDefinition: type: PrebuiltDockerImage - dockerImage: ghcr.io/hasura/ndc-rest:{{VERSION}} + dockerImage: ghcr.io/hasura/ndc-http:{{VERSION}} supportedEnvironmentVariables: [] commands: - update: ndc-rest-schema update + update: ndc-http-schema update cliPlugin: - name: ndc-rest + name: ndc-http version: "{{VERSION}}" dockerComposeWatch: # copy config files into the existing container and restart it diff --git a/connector-definition/config.yaml b/connector-definition/config.yaml index 52add86..b37f69e 100644 --- a/connector-definition/config.yaml +++ b/connector-definition/config.yaml @@ -1,4 +1,4 @@ -# yaml-language-server: $schema=https://raw.githubusercontent.com/hasura/ndc-rest/refs/heads/main/ndc-rest-schema/jsonschema/configuration.schema.json +# yaml-language-server: $schema=https://raw.githubusercontent.com/hasura/ndc-http/refs/heads/main/ndc-http-schema/jsonschema/configuration.schema.json output: schema.output.json strict: true forwardHeaders: @@ -8,11 +8,11 @@ forwardHeaders: concurrency: query: 1 mutation: 1 - rest: 5 + http: 5 # You can find or request pre-built configuration recipes of popular API services here: -# https://github.com/hasura/ndc-rest-recipes/tree/main/recipes +# https://github.com/hasura/ndc-http-recipes/tree/main/recipes files: - - file: https://raw.githubusercontent.com/hasura/ndc-rest/main/connector/testdata/jsonplaceholder/swagger.json + - file: https://raw.githubusercontent.com/hasura/ndc-http/main/connector/testdata/jsonplaceholder/swagger.json spec: oas2 timeout: value: 30 diff --git a/connector/cli.go b/connector/cli.go index 1ff9d3d..29a6e2f 100644 --- a/connector/cli.go +++ b/connector/cli.go @@ -1,10 +1,10 @@ -package rest +package connector import ( "github.com/hasura/ndc-sdk-go/connector" ) // Start and serve the connector API server -func Start[Configuration, State any](restConnector connector.Connector[Configuration, State], options ...connector.ServeOption) error { - return connector.Start(restConnector, options...) +func Start[Configuration, State any](HTTPConnector connector.Connector[Configuration, State], options ...connector.ServeOption) error { + return connector.Start(HTTPConnector, options...) } diff --git a/connector/connector.go b/connector/connector.go index d19c46c..33eba81 100644 --- a/connector/connector.go +++ b/connector/connector.go @@ -1,41 +1,41 @@ -package rest +package connector import ( "context" "encoding/json" "fmt" - "github.com/hasura/ndc-rest/connector/internal" - "github.com/hasura/ndc-rest/ndc-rest-schema/configuration" - rest "github.com/hasura/ndc-rest/ndc-rest-schema/schema" + "github.com/hasura/ndc-http/connector/internal" + "github.com/hasura/ndc-http/ndc-http-schema/configuration" + rest "github.com/hasura/ndc-http/ndc-http-schema/schema" "github.com/hasura/ndc-sdk-go/connector" "github.com/hasura/ndc-sdk-go/schema" ) -// RESTConnector implements the SDK interface of NDC specification -type RESTConnector struct { +// HTTPConnector implements the SDK interface of NDC specification +type HTTPConnector struct { config *configuration.Configuration metadata internal.MetadataCollection capabilities *schema.RawCapabilitiesResponse rawSchema *schema.RawSchemaResponse - schema *rest.NDCRestSchema + schema *rest.NDCHttpSchema client *internal.HTTPClient } -// NewRESTConnector creates a REST connector instance -func NewRESTConnector(opts ...Option) *RESTConnector { +// NewHTTPConnector creates a HTTP connector instance +func NewHTTPConnector(opts ...Option) *HTTPConnector { for _, opt := range opts { opt(&defaultOptions) } - return &RESTConnector{ + return &HTTPConnector{ client: internal.NewHTTPClient(defaultOptions.client), } } // ParseConfiguration validates the configuration files provided by the user, returning a validated 'Configuration', // or throwing an error to prevents Connector startup. -func (c *RESTConnector) ParseConfiguration(ctx context.Context, configurationDir string) (*configuration.Configuration, error) { +func (c *HTTPConnector) ParseConfiguration(ctx context.Context, configurationDir string) (*configuration.Configuration, error) { restCapabilities := schema.CapabilitiesResponse{ Version: "0.1.6", Capabilities: schema.Capabilities{ @@ -75,7 +75,7 @@ func (c *RESTConnector) ParseConfiguration(ctx context.Context, configurationDir } } - if err := c.ApplyNDCRestSchemas(config, schemas, logger); err != nil { + if err := c.ApplyNDCHttpSchemas(config, schemas, logger); err != nil { return nil, errInvalidSchema } @@ -91,7 +91,7 @@ func (c *RESTConnector) ParseConfiguration(ctx context.Context, configurationDir // // In addition, this function should register any // connector-specific metrics with the metrics registry. -func (c *RESTConnector) TryInitState(ctx context.Context, configuration *configuration.Configuration, metrics *connector.TelemetryState) (*State, error) { +func (c *HTTPConnector) TryInitState(ctx context.Context, configuration *configuration.Configuration, metrics *connector.TelemetryState) (*State, error) { c.client.SetTracer(metrics.Tracer) return &State{ @@ -105,11 +105,11 @@ func (c *RESTConnector) TryInitState(ctx context.Context, configuration *configu // is able to reach its data source over the network. // // Should throw if the check fails, else resolve. -func (c *RESTConnector) HealthCheck(ctx context.Context, configuration *configuration.Configuration, state *State) error { +func (c *HTTPConnector) HealthCheck(ctx context.Context, configuration *configuration.Configuration, state *State) error { return nil } // GetCapabilities get the connector's capabilities. -func (c *RESTConnector) GetCapabilities(configuration *configuration.Configuration) schema.CapabilitiesResponseMarshaler { +func (c *HTTPConnector) GetCapabilities(configuration *configuration.Configuration) schema.CapabilitiesResponseMarshaler { return c.capabilities } diff --git a/connector/connector_test.go b/connector/connector_test.go index 2f6f82a..3e5046d 100644 --- a/connector/connector_test.go +++ b/connector/connector_test.go @@ -1,4 +1,4 @@ -package rest +package connector import ( "bytes" @@ -15,13 +15,13 @@ import ( "testing" "time" - "github.com/hasura/ndc-rest/ndc-rest-schema/configuration" + "github.com/hasura/ndc-http/ndc-http-schema/configuration" "github.com/hasura/ndc-sdk-go/connector" "github.com/hasura/ndc-sdk-go/schema" "gotest.tools/v3/assert" ) -func TestRESTConnector(t *testing.T) { +func TestHTTPConnector(t *testing.T) { testCases := []struct { Name string Dir string @@ -83,20 +83,20 @@ func TestRESTConnector(t *testing.T) { } } -func TestRESTConnector_configurationFailure(t *testing.T) { - c := NewRESTConnector() +func TestHTTPConnector_configurationFailure(t *testing.T) { + c := NewHTTPConnector() _, err := c.ParseConfiguration(context.Background(), "") assert.ErrorContains(t, err, "the config.{json,yaml,yml} file does not exist at") } -func TestRESTConnector_emptyServer(t *testing.T) { - _, err := connector.NewServer(NewRESTConnector(), &connector.ServerOptions{ +func TestHTTPConnector_emptyServer(t *testing.T) { + _, err := connector.NewServer(NewHTTPConnector(), &connector.ServerOptions{ Configuration: "testdata/server-empty", }, connector.WithoutRecovery()) - assert.Error(t, err, "failed to build NDC REST schema") + assert.Error(t, err, "failed to build NDC HTTP schema") } -func TestRESTConnector_authentication(t *testing.T) { +func TestHTTPConnector_authentication(t *testing.T) { apiKey := "random_api_key" bearerToken := "random_bearer_token" // slog.SetLogLoggerLevel(slog.LevelDebug) @@ -106,7 +106,7 @@ func TestRESTConnector_authentication(t *testing.T) { t.Setenv("PET_STORE_URL", server.URL) t.Setenv("PET_STORE_API_KEY", apiKey) t.Setenv("PET_STORE_BEARER_TOKEN", bearerToken) - connServer, err := connector.NewServer(NewRESTConnector(), &connector.ServerOptions{ + connServer, err := connector.NewServer(NewHTTPConnector(), &connector.ServerOptions{ Configuration: "testdata/auth", }, connector.WithoutRecovery()) assert.NilError(t, err) @@ -323,7 +323,7 @@ func TestRESTConnector_authentication(t *testing.T) { } -func TestRESTConnector_distribution(t *testing.T) { +func TestHTTPConnector_distribution(t *testing.T) { apiKey := "random_api_key" bearerToken := "random_bearer_token" @@ -338,7 +338,7 @@ func TestRESTConnector_distribution(t *testing.T) { t.Setenv("PET_STORE_DOG_URL", fmt.Sprintf("%s/dog", server.URL)) t.Setenv("PET_STORE_CAT_URL", fmt.Sprintf("%s/cat", server.URL)) - rc := NewRESTConnector() + rc := NewHTTPConnector() connServer, err := connector.NewServer(rc, &connector.ServerOptions{ Configuration: "testdata/patch", }, connector.WithoutRecovery()) @@ -404,7 +404,7 @@ func TestRESTConnector_distribution(t *testing.T) { t.Setenv("PET_STORE_DOG_URL", fmt.Sprintf("%s/dog", server.URL)) t.Setenv("PET_STORE_CAT_URL", fmt.Sprintf("%s/cat", server.URL)) - rc := NewRESTConnector() + rc := NewHTTPConnector() connServer, err := connector.NewServer(rc, &connector.ServerOptions{ Configuration: "testdata/patch", }, connector.WithoutRecovery()) @@ -422,7 +422,7 @@ func TestRESTConnector_distribution(t *testing.T) { "body": { "name": "pet" }, - "restOptions": { + "httpOptions": { "parallel": true } } @@ -466,7 +466,7 @@ func TestRESTConnector_distribution(t *testing.T) { t.Setenv("PET_STORE_DOG_URL", fmt.Sprintf("%s/dog", server.URL)) t.Setenv("PET_STORE_CAT_URL", fmt.Sprintf("%s/cat", server.URL)) - rc := NewRESTConnector() + rc := NewHTTPConnector() connServer, err := connector.NewServer(rc, &connector.ServerOptions{ Configuration: "testdata/patch", }, connector.WithoutRecovery()) @@ -486,7 +486,7 @@ func TestRESTConnector_distribution(t *testing.T) { } }, "arguments": { - "restOptions": { + "httpOptions": { "type": "literal", "value": { "servers": ["cat"] @@ -521,7 +521,7 @@ func TestRESTConnector_distribution(t *testing.T) { }) } -func TestRESTConnector_multiSchemas(t *testing.T) { +func TestHTTPConnector_multiSchemas(t *testing.T) { mock := mockMultiSchemaServer{} server := mock.createServer() defer server.Close() @@ -529,7 +529,7 @@ func TestRESTConnector_multiSchemas(t *testing.T) { t.Setenv("CAT_STORE_URL", fmt.Sprintf("%s/cat", server.URL)) t.Setenv("DOG_STORE_URL", fmt.Sprintf("%s/dog", server.URL)) - connServer, err := connector.NewServer(NewRESTConnector(), &connector.ServerOptions{ + connServer, err := connector.NewServer(NewHTTPConnector(), &connector.ServerOptions{ Configuration: "testdata/multi-schemas", }, connector.WithoutRecovery()) assert.NilError(t, err) @@ -798,7 +798,7 @@ func assertNdcOperations(t *testing.T, dir string, targetURL string) { func test_createServer(t *testing.T, dir string) *connector.Server[configuration.Configuration, State] { t.Helper() - c := NewRESTConnector() + c := NewHTTPConnector() server, err := connector.NewServer(c, &connector.ServerOptions{ Configuration: dir, }, connector.WithoutRecovery()) diff --git a/connector/internal/client.go b/connector/internal/client.go index 3374b90..e259b71 100644 --- a/connector/internal/client.go +++ b/connector/internal/client.go @@ -16,7 +16,7 @@ import ( "sync" "time" - rest "github.com/hasura/ndc-rest/ndc-rest-schema/schema" + rest "github.com/hasura/ndc-http/ndc-http-schema/schema" "github.com/hasura/ndc-sdk-go/connector" "github.com/hasura/ndc-sdk-go/schema" "github.com/hasura/ndc-sdk-go/utils" @@ -54,13 +54,13 @@ func (client *HTTPClient) SetTracer(tracer *connector.Tracer) { } // Send creates and executes the request and evaluate response selection -func (client *HTTPClient) Send(ctx context.Context, request *RetryableRequest, selection schema.NestedField, resultType schema.Type, restOptions *RESTOptions) (any, http.Header, error) { - requests, err := BuildDistributedRequestsWithOptions(request, restOptions) +func (client *HTTPClient) Send(ctx context.Context, request *RetryableRequest, selection schema.NestedField, resultType schema.Type, httpOptions *HTTPOptions) (any, http.Header, error) { + requests, err := BuildDistributedRequestsWithOptions(request, httpOptions) if err != nil { return nil, nil, err } - if !restOptions.Distributed { + if !httpOptions.Distributed { result, headers, err := client.sendSingle(ctx, &requests[0], selection, resultType, requests[0].ServerID, "single") if err != nil { return nil, nil, err @@ -69,13 +69,13 @@ func (client *HTTPClient) Send(ctx context.Context, request *RetryableRequest, s return result, headers, nil } - if !restOptions.Parallel || restOptions.Concurrency <= 1 { + if !httpOptions.Parallel || httpOptions.Concurrency <= 1 { results, headers := client.sendSequence(ctx, requests, selection, resultType) return results, headers, nil } - results, headers := client.sendParallel(ctx, requests, selection, resultType, restOptions) + results, headers := client.sendParallel(ctx, requests, selection, resultType, httpOptions) return results, headers, nil } @@ -108,13 +108,13 @@ func (client *HTTPClient) sendSequence(ctx context.Context, requests []Retryable } // execute a request to a list of remote servers in parallel -func (client *HTTPClient) sendParallel(ctx context.Context, requests []RetryableRequest, selection schema.NestedField, resultType schema.Type, restOptions *RESTOptions) (*DistributedResponse[any], http.Header) { +func (client *HTTPClient) sendParallel(ctx context.Context, requests []RetryableRequest, selection schema.NestedField, resultType schema.Type, httpOptions *HTTPOptions) (*DistributedResponse[any], http.Header) { results := NewDistributedResponse[any]() var firstHeaders http.Header var lock sync.Mutex eg, ctx := errgroup.WithContext(ctx) - if restOptions.Concurrency > 0 { - eg.SetLimit(int(restOptions.Concurrency)) + if httpOptions.Concurrency > 0 { + eg.SetLimit(int(httpOptions.Concurrency)) } sendFunc := func(req RetryableRequest) { @@ -253,7 +253,7 @@ func (client *HTTPClient) doRequest(ctx context.Context, request *RetryableReque requestURL := request.URL.String() span.SetAttributes( - attribute.String("db.system", "rest"), + attribute.String("db.system", "http"), attribute.String("http.request.method", method), attribute.String("url.full", requestURL), attribute.String("server.address", request.URL.Hostname()), diff --git a/connector/internal/metadata.go b/connector/internal/metadata.go index 73d33eb..51c7acc 100644 --- a/connector/internal/metadata.go +++ b/connector/internal/metadata.go @@ -1,32 +1,32 @@ package internal import ( - "github.com/hasura/ndc-rest/ndc-rest-schema/configuration" - rest "github.com/hasura/ndc-rest/ndc-rest-schema/schema" + "github.com/hasura/ndc-http/ndc-http-schema/configuration" + rest "github.com/hasura/ndc-http/ndc-http-schema/schema" "github.com/hasura/ndc-sdk-go/schema" ) -// MetadataCollection stores list of REST metadata with helper methods -type MetadataCollection []configuration.NDCRestRuntimeSchema +// MetadataCollection stores list of HTTP metadata with helper methods +type MetadataCollection []configuration.NDCHttpRuntimeSchema // GetFunction gets the NDC function by name -func (rms MetadataCollection) GetFunction(name string) (*rest.OperationInfo, configuration.NDCRestRuntimeSchema, error) { +func (rms MetadataCollection) GetFunction(name string) (*rest.OperationInfo, configuration.NDCHttpRuntimeSchema, error) { for _, rm := range rms { fn := rm.GetFunction(name) if fn != nil { return fn, rm, nil } } - return nil, configuration.NDCRestRuntimeSchema{}, schema.UnprocessableContentError("unsupported query: "+name, nil) + return nil, configuration.NDCHttpRuntimeSchema{}, schema.UnprocessableContentError("unsupported query: "+name, nil) } // GetProcedure gets the NDC procedure by name -func (rms MetadataCollection) GetProcedure(name string) (*rest.OperationInfo, configuration.NDCRestRuntimeSchema, error) { +func (rms MetadataCollection) GetProcedure(name string) (*rest.OperationInfo, configuration.NDCHttpRuntimeSchema, error) { for _, rm := range rms { fn := rm.GetProcedure(name) if fn != nil { return fn, rm, nil } } - return nil, configuration.NDCRestRuntimeSchema{}, schema.UnprocessableContentError("unsupported mutation: "+name, nil) + return nil, configuration.NDCHttpRuntimeSchema{}, schema.UnprocessableContentError("unsupported mutation: "+name, nil) } diff --git a/connector/internal/multipart.go b/connector/internal/multipart.go index b23f5ef..23451e3 100644 --- a/connector/internal/multipart.go +++ b/connector/internal/multipart.go @@ -9,7 +9,7 @@ import ( "net/textproto" "strings" - "github.com/hasura/ndc-rest/ndc-rest-schema/schema" + "github.com/hasura/ndc-http/ndc-http-schema/schema" "github.com/hasura/ndc-sdk-go/utils" ) diff --git a/connector/internal/request.go b/connector/internal/request.go index 23f9381..06c9e3c 100644 --- a/connector/internal/request.go +++ b/connector/internal/request.go @@ -12,8 +12,8 @@ import ( "strings" "time" - rest "github.com/hasura/ndc-rest/ndc-rest-schema/schema" - "github.com/hasura/ndc-rest/ndc-rest-schema/utils" + rest "github.com/hasura/ndc-http/ndc-http-schema/schema" + "github.com/hasura/ndc-http/ndc-http-schema/utils" ) // RetryableRequest wraps the raw request with retryable @@ -85,18 +85,18 @@ func getBaseURLFromServers(servers []rest.ServerConfig, serverIDs []string) (*ur } // BuildDistributedRequestsWithOptions builds distributed requests with options -func BuildDistributedRequestsWithOptions(request *RetryableRequest, restOptions *RESTOptions) ([]RetryableRequest, error) { +func BuildDistributedRequestsWithOptions(request *RetryableRequest, httpOptions *HTTPOptions) ([]RetryableRequest, error) { if strings.HasPrefix(request.URL.Scheme, "http") { return []RetryableRequest{*request}, nil } - if !restOptions.Distributed || len(restOptions.Settings.Servers) == 1 { - baseURL, serverID := getBaseURLFromServers(restOptions.Settings.Servers, restOptions.Servers) + if !httpOptions.Distributed || len(httpOptions.Settings.Servers) == 1 { + baseURL, serverID := getBaseURLFromServers(httpOptions.Settings.Servers, httpOptions.Servers) request.URL.Scheme = baseURL.Scheme request.URL.Host = baseURL.Host request.URL.Path = baseURL.Path + request.URL.Path request.ServerID = serverID - if err := request.applySettings(restOptions.Settings, restOptions.Explain); err != nil { + if err := request.applySettings(httpOptions.Settings, httpOptions.Explain); err != nil { return nil, err } return []RetryableRequest{*request}, nil @@ -105,21 +105,21 @@ func BuildDistributedRequestsWithOptions(request *RetryableRequest, restOptions var requests []RetryableRequest var buf []byte var err error - if restOptions.Parallel && request.Body != nil { + if httpOptions.Parallel && request.Body != nil { // copy new readers for each requests to avoid race condition buf, err = io.ReadAll(request.Body) if err != nil { return nil, fmt.Errorf("failed to read request body: %w", err) } } - serverIDs := restOptions.Servers + serverIDs := httpOptions.Servers if len(serverIDs) == 0 { - for _, server := range restOptions.Settings.Servers { + for _, server := range httpOptions.Settings.Servers { serverIDs = append(serverIDs, server.ID) } } for _, serverID := range serverIDs { - baseURL, serverID := getBaseURLFromServers(restOptions.Settings.Servers, []string{serverID}) + baseURL, serverID := getBaseURLFromServers(httpOptions.Settings.Servers, []string{serverID}) if baseURL == nil { continue } @@ -134,7 +134,7 @@ func BuildDistributedRequestsWithOptions(request *RetryableRequest, restOptions Headers: request.Headers.Clone(), Body: request.Body, } - if err := req.applySettings(restOptions.Settings, restOptions.Explain); err != nil { + if err := req.applySettings(httpOptions.Settings, httpOptions.Explain); err != nil { return nil, err } if len(buf) > 0 { @@ -145,7 +145,7 @@ func BuildDistributedRequestsWithOptions(request *RetryableRequest, restOptions return requests, nil } -func (req *RetryableRequest) getServerConfig(settings *rest.NDCRestSettings) *rest.ServerConfig { +func (req *RetryableRequest) getServerConfig(settings *rest.NDCHttpSettings) *rest.ServerConfig { if settings == nil { return nil } @@ -244,7 +244,7 @@ func (req *RetryableRequest) applySecurity(serverConfig *rest.ServerConfig, isEx return nil } -func (req *RetryableRequest) applySettings(settings *rest.NDCRestSettings, isExplain bool) error { +func (req *RetryableRequest) applySettings(settings *rest.NDCHttpSettings, isExplain bool) error { if settings == nil { return nil } diff --git a/connector/internal/request_builder.go b/connector/internal/request_builder.go index 5b7648e..e3309a9 100644 --- a/connector/internal/request_builder.go +++ b/connector/internal/request_builder.go @@ -11,21 +11,21 @@ import ( "slices" "strings" - rest "github.com/hasura/ndc-rest/ndc-rest-schema/schema" + rest "github.com/hasura/ndc-http/ndc-http-schema/schema" "github.com/hasura/ndc-sdk-go/schema" "github.com/hasura/ndc-sdk-go/utils" ) // RequestBuilder builds requests to the remote service type RequestBuilder struct { - Schema *rest.NDCRestSchema + Schema *rest.NDCHttpSchema Operation *rest.OperationInfo Arguments map[string]any Runtime rest.RuntimeSettings } // NewRequestBuilder creates a new RequestBuilder instance -func NewRequestBuilder(restSchema *rest.NDCRestSchema, operation *rest.OperationInfo, arguments map[string]any, runtime rest.RuntimeSettings) *RequestBuilder { +func NewRequestBuilder(restSchema *rest.NDCHttpSchema, operation *rest.OperationInfo, arguments map[string]any, runtime rest.RuntimeSettings) *RequestBuilder { return &RequestBuilder{ Schema: restSchema, Operation: operation, @@ -143,7 +143,7 @@ func (c *RequestBuilder) createFormURLEncoded(bodyInfo *rest.ArgumentInfo, bodyD ObjectField: schema.ObjectField{ Type: bodyInfo.Type, }, - Rest: bodyInfo.Rest.Schema, + HTTP: bodyInfo.HTTP.Schema, }, reflect.ValueOf(bodyData), []string{"body"}) if err != nil { return nil, err @@ -155,7 +155,7 @@ func (c *RequestBuilder) createFormURLEncoded(bodyInfo *rest.ArgumentInfo, bodyD q := url.Values{} for _, qp := range queryParams { keys := qp.Keys() - evalQueryParameterURL(&q, "", bodyInfo.Rest.EncodingObject, keys, qp.Values()) + evalQueryParameterURL(&q, "", bodyInfo.HTTP.EncodingObject, keys, qp.Values()) } rawQuery := encodeQueryValues(q, true) @@ -195,7 +195,7 @@ func (c *RequestBuilder) evalMultipartForm(w *MultipartWriter, bodyInfo *rest.Ar ArgumentInfo: schema.ArgumentInfo{ Type: bodyType.UnderlyingType, }, - Rest: bodyInfo.Rest, + HTTP: bodyInfo.HTTP, }, bodyData) case *schema.NamedType: if !ok { @@ -287,7 +287,7 @@ func (c *RequestBuilder) evalMultipartFieldValueRecursive(w *MultipartWriter, na ObjectField: schema.ObjectField{ Type: argType.ElementType, }, - Rest: fieldInfo.Rest.Items, + HTTP: fieldInfo.HTTP.Items, }, enc) if err != nil { return err @@ -302,7 +302,7 @@ func (c *RequestBuilder) evalMultipartFieldValueRecursive(w *MultipartWriter, na ObjectField: schema.ObjectField{ Type: argType.UnderlyingType, }, - Rest: fieldInfo.Rest, + HTTP: fieldInfo.HTTP, }, enc) case *schema.NamedType: if !notNull { @@ -388,7 +388,7 @@ func (c *RequestBuilder) evalEncodingHeaders(encHeaders map[string]rest.RequestP ObjectField: schema.ObjectField{ Type: argumentInfo.Type, }, - Rest: param.Schema, + HTTP: param.Schema, }, reflect.ValueOf(rawHeaderValue), []string{}) if err != nil { return nil, err diff --git a/connector/internal/request_builder_test.go b/connector/internal/request_builder_test.go index ebebe3d..0885a01 100644 --- a/connector/internal/request_builder_test.go +++ b/connector/internal/request_builder_test.go @@ -11,7 +11,7 @@ import ( "strings" "testing" - rest "github.com/hasura/ndc-rest/ndc-rest-schema/schema" + rest "github.com/hasura/ndc-http/ndc-http-schema/schema" "gotest.tools/v3/assert" ) @@ -588,9 +588,9 @@ func TestCreateFormURLEncoded(t *testing.T) { } } -func createMockSchema(t *testing.T) *rest.NDCRestSchema { - var ndcSchema rest.NDCRestSchema - rawSchemaBytes, err := os.ReadFile("../../ndc-rest-schema/openapi/testdata/petstore3/expected.json") +func createMockSchema(t *testing.T) *rest.NDCHttpSchema { + var ndcSchema rest.NDCHttpSchema + rawSchemaBytes, err := os.ReadFile("../../ndc-http-schema/openapi/testdata/petstore3/expected.json") assert.NilError(t, err) assert.NilError(t, json.Unmarshal(rawSchemaBytes, &ndcSchema)) return &ndcSchema diff --git a/connector/internal/request_parameter.go b/connector/internal/request_parameter.go index 34fd25f..b878b80 100644 --- a/connector/internal/request_parameter.go +++ b/connector/internal/request_parameter.go @@ -12,7 +12,7 @@ import ( "time" "github.com/google/uuid" - rest "github.com/hasura/ndc-rest/ndc-rest-schema/schema" + rest "github.com/hasura/ndc-http/ndc-http-schema/schema" "github.com/hasura/ndc-sdk-go/schema" "github.com/hasura/ndc-sdk-go/utils" sdkUtils "github.com/hasura/ndc-sdk-go/utils" @@ -38,7 +38,7 @@ func (c *RequestBuilder) evalURLAndHeaderParameters() (*url.URL, http.Header, er } for argumentKey, argumentInfo := range c.Operation.Arguments { - if argumentInfo.Rest == nil || !slices.Contains(urlAndHeaderLocations, argumentInfo.Rest.In) { + if argumentInfo.HTTP == nil || !slices.Contains(urlAndHeaderLocations, argumentInfo.HTTP.In) { continue } if err := c.evalURLAndHeaderParameterBySchema(endpoint, &headers, argumentKey, &argumentInfo, c.Arguments[argumentKey]); err != nil { @@ -52,14 +52,14 @@ func (c *RequestBuilder) evalURLAndHeaderParameters() (*url.URL, http.Header, er // // [OAS 3.1 spec]: https://swagger.io/docs/specification/serialization/ func (c *RequestBuilder) evalURLAndHeaderParameterBySchema(endpoint *url.URL, header *http.Header, argumentKey string, argumentInfo *rest.ArgumentInfo, value any) error { - if argumentInfo.Rest.Name != "" { - argumentKey = argumentInfo.Rest.Name + if argumentInfo.HTTP.Name != "" { + argumentKey = argumentInfo.HTTP.Name } queryParams, err := c.encodeParameterValues(&rest.ObjectField{ ObjectField: schema.ObjectField{ Type: argumentInfo.Type, }, - Rest: argumentInfo.Rest.Schema, + HTTP: argumentInfo.HTTP.Schema, }, reflect.ValueOf(value), []string{argumentKey}) if err != nil { return err @@ -72,15 +72,15 @@ func (c *RequestBuilder) evalURLAndHeaderParameterBySchema(endpoint *url.URL, he // following the OAS spec to serialize parameters // https://swagger.io/docs/specification/serialization/ // https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#parameter-object - switch argumentInfo.Rest.In { + switch argumentInfo.HTTP.In { case rest.InHeader: - setHeaderParameters(header, argumentInfo.Rest, queryParams) + setHeaderParameters(header, argumentInfo.HTTP, queryParams) case rest.InQuery: q := endpoint.Query() for _, qp := range queryParams { - evalQueryParameterURL(&q, argumentKey, argumentInfo.Rest.EncodingObject, qp.Keys(), qp.Values()) + evalQueryParameterURL(&q, argumentKey, argumentInfo.HTTP.EncodingObject, qp.Keys(), qp.Values()) } - endpoint.RawQuery = encodeQueryValues(q, argumentInfo.Rest.AllowReserved) + endpoint.RawQuery = encodeQueryValues(q, argumentInfo.HTTP.AllowReserved) case rest.InPath: defaultParam := queryParams.FindDefault() if defaultParam != nil { @@ -93,7 +93,7 @@ func (c *RequestBuilder) evalURLAndHeaderParameterBySchema(endpoint *url.URL, he func (c *RequestBuilder) encodeParameterValues(objectField *rest.ObjectField, reflectValue reflect.Value, fieldPaths []string) (ParameterItems, error) { results := ParameterItems{} - typeSchema := objectField.Rest + typeSchema := objectField.HTTP reflectValue, nonNull := sdkUtils.UnwrapPointerFromReflectValue(reflectValue) switch ty := objectField.Type.Interface().(type) { @@ -105,7 +105,7 @@ func (c *RequestBuilder) encodeParameterValues(objectField *rest.ObjectField, re ObjectField: schema.ObjectField{ Type: ty.UnderlyingType, }, - Rest: typeSchema, + HTTP: typeSchema, }, reflectValue, fieldPaths) case *schema.ArrayType: if !nonNull { @@ -122,7 +122,7 @@ func (c *RequestBuilder) encodeParameterValues(objectField *rest.ObjectField, re ObjectField: schema.ObjectField{ Type: ty.ElementType, }, - Rest: typeSchema.Items, + HTTP: typeSchema.Items, }, reflect.ValueOf(elem), propPaths) if err != nil { return nil, err diff --git a/connector/internal/request_parameter_test.go b/connector/internal/request_parameter_test.go index 23dba43..1691734 100644 --- a/connector/internal/request_parameter_test.go +++ b/connector/internal/request_parameter_test.go @@ -5,7 +5,7 @@ import ( "net/url" "testing" - rest "github.com/hasura/ndc-rest/ndc-rest-schema/schema" + rest "github.com/hasura/ndc-http/ndc-http-schema/schema" "github.com/hasura/ndc-sdk-go/utils" "gotest.tools/v3/assert" ) diff --git a/connector/internal/types.go b/connector/internal/types.go index 0c1a7a5..54798bf 100644 --- a/connector/internal/types.go +++ b/connector/internal/types.go @@ -6,7 +6,7 @@ import ( "fmt" "regexp" - rest "github.com/hasura/ndc-rest/ndc-rest-schema/schema" + rest "github.com/hasura/ndc-http/ndc-http-schema/schema" "github.com/hasura/ndc-sdk-go/schema" "github.com/hasura/ndc-sdk-go/utils" ) @@ -26,29 +26,29 @@ var ( var defaultRetryHTTPStatus = []int{429, 500, 502, 503} var sensitiveHeaderRegex = regexp.MustCompile(`auth|key|secret|token`) -// RESTOptions represent execution options for REST requests -type RESTOptions struct { +// HTTPOptions represent execution options for HTTP requests +type HTTPOptions struct { Servers []string `json:"serverIds" yaml:"serverIds"` Parallel bool `json:"parallel" yaml:"parallel"` Explain bool `json:"-" yaml:"-"` Distributed bool `json:"-" yaml:"-"` Concurrency uint `json:"-" yaml:"-"` - Settings *rest.NDCRestSettings `json:"-" yaml:"-"` + Settings *rest.NDCHttpSettings `json:"-" yaml:"-"` } -// FromValue parses rest execution options from any value -func (ro *RESTOptions) FromValue(value any) error { +// FromValue parses http execution options from any value +func (ro *HTTPOptions) FromValue(value any) error { if utils.IsNil(value) { return nil } valueMap, ok := value.(map[string]any) if !ok { - return fmt.Errorf("invalid rest options; expected object, got %v", value) + return fmt.Errorf("invalid http options; expected object, got %v", value) } rawServerIds, err := utils.GetNullableStringSlice(valueMap, "servers") if err != nil { - return fmt.Errorf("invalid rest options; %w", err) + return fmt.Errorf("invalid http options; %w", err) } if rawServerIds != nil { ro.Servers = *rawServerIds @@ -56,7 +56,7 @@ func (ro *RESTOptions) FromValue(value any) error { parallel, err := utils.GetNullableBoolean(valueMap, "parallel") if err != nil { - return fmt.Errorf("invalid parallel in rest options: %w", err) + return fmt.Errorf("invalid parallel in http options: %w", err) } ro.Parallel = parallel != nil && *parallel diff --git a/connector/mutation.go b/connector/mutation.go index 0a24990..c6ccf55 100644 --- a/connector/mutation.go +++ b/connector/mutation.go @@ -1,20 +1,20 @@ -package rest +package connector import ( "context" "encoding/json" "fmt" - "github.com/hasura/ndc-rest/connector/internal" - "github.com/hasura/ndc-rest/ndc-rest-schema/configuration" - rest "github.com/hasura/ndc-rest/ndc-rest-schema/schema" + "github.com/hasura/ndc-http/connector/internal" + "github.com/hasura/ndc-http/ndc-http-schema/configuration" + rest "github.com/hasura/ndc-http/ndc-http-schema/schema" "github.com/hasura/ndc-sdk-go/schema" "go.opentelemetry.io/otel/codes" "golang.org/x/sync/errgroup" ) // Mutation executes a mutation. -func (c *RESTConnector) Mutation(ctx context.Context, configuration *configuration.Configuration, state *State, request *schema.MutationRequest) (*schema.MutationResponse, error) { +func (c *HTTPConnector) Mutation(ctx context.Context, configuration *configuration.Configuration, state *State, request *schema.MutationRequest) (*schema.MutationResponse, error) { if len(request.Operations) == 1 || c.config.Concurrency.Mutation <= 1 { return c.execMutationSync(ctx, state, request) } @@ -23,7 +23,7 @@ func (c *RESTConnector) Mutation(ctx context.Context, configuration *configurati } // MutationExplain explains a mutation by creating an execution plan. -func (c *RESTConnector) MutationExplain(ctx context.Context, configuration *configuration.Configuration, state *State, request *schema.MutationRequest) (*schema.ExplainResponse, error) { +func (c *HTTPConnector) MutationExplain(ctx context.Context, configuration *configuration.Configuration, state *State, request *schema.MutationRequest) (*schema.ExplainResponse, error) { if len(request.Operations) == 0 { return &schema.ExplainResponse{ Details: schema.ExplainResponseDetails{}, @@ -32,18 +32,18 @@ func (c *RESTConnector) MutationExplain(ctx context.Context, configuration *conf operation := request.Operations[0] switch operation.Type { case schema.MutationOperationProcedure: - httpRequest, _, restOptions, err := c.explainProcedure(&operation) + httpRequest, _, httpOptions, err := c.explainProcedure(&operation) if err != nil { return nil, err } - return serializeExplainResponse(httpRequest, restOptions) + return serializeExplainResponse(httpRequest, httpOptions) default: return nil, schema.BadRequestError(fmt.Sprintf("invalid operation type: %s", operation.Type), nil) } } -func (c *RESTConnector) explainProcedure(operation *schema.MutationOperation) (*internal.RetryableRequest, *rest.OperationInfo, *internal.RESTOptions, error) { +func (c *HTTPConnector) explainProcedure(operation *schema.MutationOperation) (*internal.RetryableRequest, *rest.OperationInfo, *internal.HTTPOptions, error) { procedure, metadata, err := c.metadata.GetProcedure(operation.Name) if err != nil { return nil, nil, nil, err @@ -70,18 +70,18 @@ func (c *RESTConnector) explainProcedure(operation *schema.MutationOperation) (* }) } - restOptions, err := c.parseRESTOptionsFromArguments(procedure.Arguments, rawArgs) + httpOptions, err := c.parseHTTPOptionsFromArguments(procedure.Arguments, rawArgs) if err != nil { - return nil, nil, nil, schema.UnprocessableContentError("invalid rest options", map[string]any{ + return nil, nil, nil, schema.UnprocessableContentError("invalid http options", map[string]any{ "cause": err.Error(), }) } - restOptions.Settings = metadata.Settings - return httpRequest, procedure, restOptions, nil + httpOptions.Settings = metadata.Settings + return httpRequest, procedure, httpOptions, nil } -func (c *RESTConnector) execMutationSync(ctx context.Context, state *State, request *schema.MutationRequest) (*schema.MutationResponse, error) { +func (c *HTTPConnector) execMutationSync(ctx context.Context, state *State, request *schema.MutationRequest) (*schema.MutationResponse, error) { operationResults := make([]schema.MutationOperationResults, len(request.Operations)) for i, operation := range request.Operations { result, err := c.execMutationOperation(ctx, state, operation, i) @@ -96,7 +96,7 @@ func (c *RESTConnector) execMutationSync(ctx context.Context, state *State, requ }, nil } -func (c *RESTConnector) execMutationAsync(ctx context.Context, state *State, request *schema.MutationRequest) (*schema.MutationResponse, error) { +func (c *HTTPConnector) execMutationAsync(ctx context.Context, state *State, request *schema.MutationRequest) (*schema.MutationResponse, error) { operationResults := make([]schema.MutationOperationResults, len(request.Operations)) eg, ctx := errgroup.WithContext(ctx) @@ -125,11 +125,11 @@ func (c *RESTConnector) execMutationAsync(ctx context.Context, state *State, req }, nil } -func (c *RESTConnector) execMutationOperation(parentCtx context.Context, state *State, operation schema.MutationOperation, index int) (schema.MutationOperationResults, error) { +func (c *HTTPConnector) execMutationOperation(parentCtx context.Context, state *State, operation schema.MutationOperation, index int) (schema.MutationOperationResults, error) { ctx, span := state.Tracer.Start(parentCtx, fmt.Sprintf("Execute Operation %d", index)) defer span.End() - httpRequest, procedure, restOptions, err := c.explainProcedure(&operation) + httpRequest, procedure, httpOptions, err := c.explainProcedure(&operation) if err != nil { span.SetStatus(codes.Error, "failed to explain mutation") span.RecordError(err) @@ -137,8 +137,8 @@ func (c *RESTConnector) execMutationOperation(parentCtx context.Context, state * return nil, err } - restOptions.Concurrency = c.config.Concurrency.REST - result, headers, err := c.client.Send(ctx, httpRequest, operation.Fields, procedure.ResultType, restOptions) + httpOptions.Concurrency = c.config.Concurrency.HTTP + result, headers, err := c.client.Send(ctx, httpRequest, operation.Fields, procedure.ResultType, httpOptions) if err != nil { span.SetStatus(codes.Error, "failed to execute mutation") span.RecordError(err) diff --git a/connector/query.go b/connector/query.go index 384e9a1..b0347dc 100644 --- a/connector/query.go +++ b/connector/query.go @@ -1,4 +1,4 @@ -package rest +package connector import ( "context" @@ -6,9 +6,9 @@ import ( "fmt" "io" - "github.com/hasura/ndc-rest/connector/internal" - "github.com/hasura/ndc-rest/ndc-rest-schema/configuration" - rest "github.com/hasura/ndc-rest/ndc-rest-schema/schema" + "github.com/hasura/ndc-http/connector/internal" + "github.com/hasura/ndc-http/ndc-http-schema/configuration" + rest "github.com/hasura/ndc-http/ndc-http-schema/schema" "github.com/hasura/ndc-sdk-go/schema" "github.com/hasura/ndc-sdk-go/utils" "go.opentelemetry.io/otel/codes" @@ -16,7 +16,7 @@ import ( ) // Query executes a query. -func (c *RESTConnector) Query(ctx context.Context, configuration *configuration.Configuration, state *State, request *schema.QueryRequest) (schema.QueryResponse, error) { +func (c *HTTPConnector) Query(ctx context.Context, configuration *configuration.Configuration, state *State, request *schema.QueryRequest) (schema.QueryResponse, error) { valueField, err := utils.EvalFunctionSelectionFieldValue(request) if err != nil { return nil, schema.UnprocessableContentError(err.Error(), nil) @@ -34,21 +34,21 @@ func (c *RESTConnector) Query(ctx context.Context, configuration *configuration. } // QueryExplain explains a query by creating an execution plan. -func (c *RESTConnector) QueryExplain(ctx context.Context, configuration *configuration.Configuration, state *State, request *schema.QueryRequest) (*schema.ExplainResponse, error) { +func (c *HTTPConnector) QueryExplain(ctx context.Context, configuration *configuration.Configuration, state *State, request *schema.QueryRequest) (*schema.ExplainResponse, error) { requestVars := request.Variables if len(requestVars) == 0 { requestVars = []schema.QueryRequestVariablesElem{make(schema.QueryRequestVariablesElem)} } - httpRequest, _, restOptions, err := c.explainQuery(request, requestVars[0]) + httpRequest, _, httpOptions, err := c.explainQuery(request, requestVars[0]) if err != nil { return nil, err } - return serializeExplainResponse(httpRequest, restOptions) + return serializeExplainResponse(httpRequest, httpOptions) } -func (c *RESTConnector) explainQuery(request *schema.QueryRequest, variables map[string]any) (*internal.RetryableRequest, *rest.OperationInfo, *internal.RESTOptions, error) { +func (c *HTTPConnector) explainQuery(request *schema.QueryRequest, variables map[string]any) (*internal.RetryableRequest, *rest.OperationInfo, *internal.HTTPOptions, error) { function, metadata, err := c.metadata.GetFunction(request.Collection) if err != nil { return nil, nil, nil, err @@ -74,19 +74,19 @@ func (c *RESTConnector) explainQuery(request *schema.QueryRequest, variables map }) } - restOptions, err := c.parseRESTOptionsFromArguments(function.Arguments, rawArgs) + httpOptions, err := c.parseHTTPOptionsFromArguments(function.Arguments, rawArgs) if err != nil { - return nil, nil, nil, schema.UnprocessableContentError("invalid rest options", map[string]any{ + return nil, nil, nil, schema.UnprocessableContentError("invalid http options", map[string]any{ "cause": err.Error(), }) } - restOptions.Settings = metadata.Settings + httpOptions.Settings = metadata.Settings - return req, function, restOptions, err + return req, function, httpOptions, err } -func (c *RESTConnector) execQuerySync(ctx context.Context, state *State, request *schema.QueryRequest, valueField schema.NestedField, requestVars []schema.QueryRequestVariablesElem) ([]schema.RowSet, error) { +func (c *HTTPConnector) execQuerySync(ctx context.Context, state *State, request *schema.QueryRequest, valueField schema.NestedField, requestVars []schema.QueryRequestVariablesElem) ([]schema.RowSet, error) { rowSets := make([]schema.RowSet, len(requestVars)) for i, requestVar := range requestVars { @@ -107,7 +107,7 @@ func (c *RESTConnector) execQuerySync(ctx context.Context, state *State, request return rowSets, nil } -func (c *RESTConnector) execQueryAsync(ctx context.Context, state *State, request *schema.QueryRequest, valueField schema.NestedField, requestVars []schema.QueryRequestVariablesElem) ([]schema.RowSet, error) { +func (c *HTTPConnector) execQueryAsync(ctx context.Context, state *State, request *schema.QueryRequest, valueField schema.NestedField, requestVars []schema.QueryRequestVariablesElem) ([]schema.RowSet, error) { rowSets := make([]schema.RowSet, len(requestVars)) eg, ctx := errgroup.WithContext(ctx) @@ -141,11 +141,11 @@ func (c *RESTConnector) execQueryAsync(ctx context.Context, state *State, reques return rowSets, nil } -func (c *RESTConnector) execQuery(ctx context.Context, state *State, request *schema.QueryRequest, queryFields schema.NestedField, variables map[string]any, index int) (any, error) { +func (c *HTTPConnector) execQuery(ctx context.Context, state *State, request *schema.QueryRequest, queryFields schema.NestedField, variables map[string]any, index int) (any, error) { ctx, span := state.Tracer.Start(ctx, fmt.Sprintf("Execute Query %d", index)) defer span.End() - httpRequest, function, restOptions, err := c.explainQuery(request, variables) + httpRequest, function, httpOptions, err := c.explainQuery(request, variables) if err != nil { span.SetStatus(codes.Error, "failed to explain query") span.RecordError(err) @@ -153,8 +153,8 @@ func (c *RESTConnector) execQuery(ctx context.Context, state *State, request *sc return nil, err } - restOptions.Concurrency = c.config.Concurrency.REST - result, headers, err := c.client.Send(ctx, httpRequest, queryFields, function.ResultType, restOptions) + httpOptions.Concurrency = c.config.Concurrency.HTTP + result, headers, err := c.client.Send(ctx, httpRequest, queryFields, function.ResultType, httpOptions) if err != nil { span.SetStatus(codes.Error, "failed to execute the http request") span.RecordError(err) @@ -165,7 +165,7 @@ func (c *RESTConnector) execQuery(ctx context.Context, state *State, request *sc return c.createHeaderForwardingResponse(result, headers), nil } -func serializeExplainResponse(httpRequest *internal.RetryableRequest, restOptions *internal.RESTOptions) (*schema.ExplainResponse, error) { +func serializeExplainResponse(httpRequest *internal.RetryableRequest, httpOptions *internal.HTTPOptions) (*schema.ExplainResponse, error) { explainResp := &schema.ExplainResponse{ Details: schema.ExplainResponseDetails{}, } @@ -180,9 +180,9 @@ func serializeExplainResponse(httpRequest *internal.RetryableRequest, restOption explainResp.Details["body"] = string(bodyBytes) } - restOptions.Distributed = false - restOptions.Explain = true - requests, err := internal.BuildDistributedRequestsWithOptions(httpRequest, restOptions) + httpOptions.Distributed = false + httpOptions.Explain = true + requests, err := internal.BuildDistributedRequestsWithOptions(httpRequest, httpOptions) if err != nil { return nil, err } diff --git a/connector/schema.go b/connector/schema.go index 57afef1..30c6100 100644 --- a/connector/schema.go +++ b/connector/schema.go @@ -1,4 +1,4 @@ -package rest +package connector import ( "context" @@ -9,20 +9,20 @@ import ( "slices" "github.com/go-viper/mapstructure/v2" - "github.com/hasura/ndc-rest/connector/internal" - "github.com/hasura/ndc-rest/ndc-rest-schema/configuration" - rest "github.com/hasura/ndc-rest/ndc-rest-schema/schema" + "github.com/hasura/ndc-http/connector/internal" + "github.com/hasura/ndc-http/ndc-http-schema/configuration" + rest "github.com/hasura/ndc-http/ndc-http-schema/schema" "github.com/hasura/ndc-sdk-go/schema" ) // GetSchema gets the connector's schema. -func (c *RESTConnector) GetSchema(ctx context.Context, configuration *configuration.Configuration, _ *State) (schema.SchemaResponseMarshaler, error) { +func (c *HTTPConnector) GetSchema(ctx context.Context, configuration *configuration.Configuration, _ *State) (schema.SchemaResponseMarshaler, error) { return c.rawSchema, nil } -// ApplyNDCRestSchemas applies slice of raw NDC REST schemas to the connector -func (c *RESTConnector) ApplyNDCRestSchemas(config *configuration.Configuration, schemas []configuration.NDCRestRuntimeSchema, logger *slog.Logger) error { - ndcSchema, metadata, errs := configuration.MergeNDCRestSchemas(config, schemas) +// ApplyNDCHttpSchemas applies slice of raw NDC HTTP schemas to the connector +func (c *HTTPConnector) ApplyNDCHttpSchemas(config *configuration.Configuration, schemas []configuration.NDCHttpRuntimeSchema, logger *slog.Logger) error { + ndcSchema, metadata, errs := configuration.MergeNDCHttpSchemas(config, schemas) if len(errs) > 0 { printSchemaValidationError(logger, errs) if ndcSchema == nil || config.Strict { @@ -35,7 +35,7 @@ func (c *RESTConnector) ApplyNDCRestSchemas(config *configuration.Configuration, return err } - c.schema = &rest.NDCRestSchema{ + c.schema = &rest.NDCHttpSchema{ ScalarTypes: ndcSchema.ScalarTypes, ObjectTypes: ndcSchema.ObjectTypes, } @@ -46,28 +46,28 @@ func (c *RESTConnector) ApplyNDCRestSchemas(config *configuration.Configuration, } func printSchemaValidationError(logger *slog.Logger, errors map[string][]string) { - logger.Error("errors happen when validating NDC REST schemas", slog.Any("errors", errors)) + logger.Error("errors happen when validating NDC HTTP schemas", slog.Any("errors", errors)) } -func (c *RESTConnector) parseRESTOptionsFromArguments(argumentsInfo map[string]rest.ArgumentInfo, rawArgs map[string]any) (*internal.RESTOptions, error) { - var result internal.RESTOptions - argInfo, ok := argumentsInfo[rest.RESTOptionsArgumentName] +func (c *HTTPConnector) parseHTTPOptionsFromArguments(argumentsInfo map[string]rest.ArgumentInfo, rawArgs map[string]any) (*internal.HTTPOptions, error) { + var result internal.HTTPOptions + argInfo, ok := argumentsInfo[rest.HTTPOptionsArgumentName] if !ok { return &result, nil } - rawRestOptions, ok := rawArgs[rest.RESTOptionsArgumentName] + rawHttpOptions, ok := rawArgs[rest.HTTPOptionsArgumentName] if ok { - if err := result.FromValue(rawRestOptions); err != nil { + if err := result.FromValue(rawHttpOptions); err != nil { return nil, err } } - restOptionsNamedType := schema.GetUnderlyingNamedType(argInfo.Type) - result.Distributed = restOptionsNamedType != nil && restOptionsNamedType.Name == rest.RESTDistributedOptionsObjectName + httpOptionsNamedType := schema.GetUnderlyingNamedType(argInfo.Type) + result.Distributed = httpOptionsNamedType != nil && httpOptionsNamedType.Name == rest.HTTPDistributedOptionsObjectName return &result, nil } -func (c *RESTConnector) evalForwardedHeaders(req *internal.RetryableRequest, rawArgs map[string]any) error { +func (c *HTTPConnector) evalForwardedHeaders(req *internal.RetryableRequest, rawArgs map[string]any) error { if !c.config.ForwardHeaders.Enabled || c.config.ForwardHeaders.ArgumentField == nil { return nil } @@ -91,7 +91,7 @@ func (c *RESTConnector) evalForwardedHeaders(req *internal.RetryableRequest, raw return nil } -func (c *RESTConnector) createHeaderForwardingResponse(result any, rawHeaders http.Header) any { +func (c *HTTPConnector) createHeaderForwardingResponse(result any, rawHeaders http.Header) any { if !c.config.ForwardHeaders.Enabled || c.config.ForwardHeaders.ResponseHeaders == nil { return result } diff --git a/connector/testdata/auth/config.yaml b/connector/testdata/auth/config.yaml index 3dcdc5f..93005fc 100644 --- a/connector/testdata/auth/config.yaml +++ b/connector/testdata/auth/config.yaml @@ -1,4 +1,4 @@ -# yaml-language-server: $schema=../../../ndc-rest-schema/jsonschema/configuration.schema.json +# yaml-language-server: $schema=../../../ndc-http-schema/jsonschema/configuration.schema.json strict: true forwardHeaders: enabled: true @@ -12,7 +12,7 @@ forwardHeaders: concurrency: query: 1 mutation: 1 - rest: 0 + http: 0 files: - file: schema.yaml spec: ndc diff --git a/connector/testdata/auth/schema.yaml b/connector/testdata/auth/schema.yaml index f8c6ba5..330691d 100644 --- a/connector/testdata/auth/schema.yaml +++ b/connector/testdata/auth/schema.yaml @@ -56,7 +56,7 @@ functions: underlying_type: name: String type: named - rest: + http: in: query schema: type: [string] @@ -102,7 +102,7 @@ procedures: type: name: Pet type: named - rest: + http: in: body description: Add a new pet to the store name: addPet diff --git a/connector/testdata/jsonplaceholder/swagger.json b/connector/testdata/jsonplaceholder/swagger.json index a1179c4..cc3f5c2 100644 --- a/connector/testdata/jsonplaceholder/swagger.json +++ b/connector/testdata/jsonplaceholder/swagger.json @@ -1,7 +1,7 @@ { "swagger": "2.0", "info": { - "description": "Fake Online REST API for Testing and Prototyping", + "description": "Fake Online HTTP API for Testing and Prototyping", "version": "1.0.0", "title": "JSON Placeholder" }, diff --git a/connector/types.go b/connector/types.go index b0c0e1b..2e07c46 100644 --- a/connector/types.go +++ b/connector/types.go @@ -1,16 +1,16 @@ -package rest +package connector import ( "errors" "net/http" - "github.com/hasura/ndc-rest/connector/internal" + "github.com/hasura/ndc-http/connector/internal" "go.opentelemetry.io/otel/trace" ) var ( - errInvalidSchema = errors.New("failed to validate NDC REST schema") - errBuildSchemaFailed = errors.New("failed to build NDC REST schema") + errInvalidSchema = errors.New("failed to validate NDC HTTP schema") + errBuildSchemaFailed = errors.New("failed to build NDC HTTP schema") ) // State is the global state which is shared for every connector request. @@ -28,7 +28,7 @@ var defaultOptions options = options{ }, } -// Option is an interface to set custom REST connector options +// Option is an interface to set custom HTTP connector options type Option (func(*options)) // WithClient sets the custom HTTP client that satisfy the Doer interface diff --git a/go.mod b/go.mod index 31314b2..39428e1 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/hasura/ndc-rest +module github.com/hasura/ndc-http go 1.23.0 @@ -7,7 +7,7 @@ toolchain go1.23.1 require ( github.com/go-viper/mapstructure/v2 v2.2.1 github.com/google/uuid v1.6.0 - github.com/hasura/ndc-rest/ndc-rest-schema v0.0.0-00010101000000-000000000000 + github.com/hasura/ndc-http/ndc-http-schema v0.0.0-00010101000000-000000000000 github.com/hasura/ndc-sdk-go v1.6.2-0.20241109102535-399b739f7af5 go.opentelemetry.io/otel v1.32.0 go.opentelemetry.io/otel/trace v1.32.0 @@ -61,4 +61,4 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect ) -replace github.com/hasura/ndc-rest/ndc-rest-schema => ./ndc-rest-schema +replace github.com/hasura/ndc-http/ndc-http-schema => ./ndc-http-schema diff --git a/go.work b/go.work index c45ceb7..432ef7a 100644 --- a/go.work +++ b/go.work @@ -2,5 +2,5 @@ go 1.23.0 use ( . - ./ndc-rest-schema + ./ndc-http-schema ) diff --git a/ndc-rest-schema/README.md b/ndc-http-schema/README.md similarity index 93% rename from ndc-rest-schema/README.md rename to ndc-http-schema/README.md index 4293efb..bfcc3bb 100644 --- a/ndc-rest-schema/README.md +++ b/ndc-http-schema/README.md @@ -1,6 +1,6 @@ -# NDC REST Schema +# NDC HTTP Schema -This module includes libraries and tools to convert other API schemas to Native Data Connector (NDC) schema, as well as extend the NDC spec with REST request information. +This module includes libraries and tools to convert other API schemas to Native Data Connector (NDC) schema, as well as extend the NDC spec with HTTP request information. ## Features @@ -20,13 +20,13 @@ This module includes libraries and tools to convert other API schemas to Native **Install** ```go -go install github.com/hasura/ndc-rest/ndc-rest-schema@latest +go install github.com/hasura/ndc-http/ndc-http-schema@latest ``` ## Quick start ```sh -Usage: ndc-rest-schema +Usage: ndc-http-schema Flags: -h, --help Show context-sensitive help. @@ -36,12 +36,12 @@ Commands: convert --file=STRING Convert API spec to NDC schema. For example: - ndc-rest-schema convert -f petstore.yaml --spec oas2 -o petstore.json + ndc-http-schema convert -f petstore.yaml --spec oas2 -o petstore.json json2yaml --file=STRING Convert JSON file to YAML. For example: - ndc-rest-schema json2yaml -f petstore.json -o petstore.yaml + ndc-http-schema json2yaml -f petstore.json -o petstore.yaml version Print the CLI version. @@ -50,7 +50,7 @@ Commands: Convert an OpenAPI v3 file to NDC schema with the `convert` command. The tool can accept either file path or URL. The output format can be in JSON or YAML, depending on the file extension: ```sh -ndc-rest-schema convert -f https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/examples/v3.0/petstore.yaml -o petstore.json --spec oas3 +ndc-http-schema convert -f https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/examples/v3.0/petstore.yaml -o petstore.json --spec oas3 ``` The `--spec` flag represents the input specification: @@ -58,22 +58,22 @@ The `--spec` flag represents the input specification: - `oas3` (`openapi3`): OpenAPI 3.0 and 3.1 (default) - `oas2` (`openapi2`): OpenAPI 2.0 -The output schema can extend from the NDC schema with REST information that will be used for the NDC REST connector. You can convert the pure NDC schema with `--pure` flag. +The output schema can extend from the NDC schema with HTTP information that will be used for the NDC HTTP connector. You can convert the pure NDC schema with `--pure` flag. You also can use a config file to convert ([example](./config.example.yaml)). Arguments will override the config file if you use both the config file and other arguments. ```sh -ndc-rest-schema convert -c ./config.yaml +ndc-http-schema convert -c ./config.yaml ``` > [!NOTE] > The tool will consider the path of the config file as the root directory. For example, if the config path is `./foo/bar/config.yaml`, the tool will look for relative patch files from `./foo/bar` folder. Extra arguments will take the execution location as the root directory. -## NDC REST configuration +## NDC HTTP configuration ### Request -The NDC REST configuration adds `request` information into `functions` and `procedures` so the connector can have more context to initiate HTTP requests to the remote REST service. The request schema is inspired by [OpenAPI 3 paths and operations](https://swagger.io/docs/specification/paths-and-operations/). +The NDC HTTP configuration adds `request` information into `functions` and `procedures` so the connector can have more context to initiate HTTP requests to the remote HTTP service. The request schema is inspired by [OpenAPI 3 paths and operations](https://swagger.io/docs/specification/paths-and-operations/). ```yaml - request: @@ -170,7 +170,7 @@ functions: underlying_type: name: String type: named - rest: + http: name: status in: query schema: @@ -203,7 +203,7 @@ procedures: type: name: Pet type: named - rest: + http: in: body schema: type: object diff --git a/ndc-rest-schema/command/convert.go b/ndc-http-schema/command/convert.go similarity index 90% rename from ndc-rest-schema/command/convert.go rename to ndc-http-schema/command/convert.go index a6e73f2..445018d 100644 --- a/ndc-rest-schema/command/convert.go +++ b/ndc-http-schema/command/convert.go @@ -8,17 +8,17 @@ import ( "path/filepath" "time" - "github.com/hasura/ndc-rest/ndc-rest-schema/configuration" - "github.com/hasura/ndc-rest/ndc-rest-schema/schema" - "github.com/hasura/ndc-rest/ndc-rest-schema/utils" + "github.com/hasura/ndc-http/ndc-http-schema/configuration" + "github.com/hasura/ndc-http/ndc-http-schema/schema" + "github.com/hasura/ndc-http/ndc-http-schema/utils" "gopkg.in/yaml.v3" ) -// ConvertToNDCSchema converts to NDC REST schema from file +// ConvertToNDCSchema converts to NDC HTTP schema from file func CommandConvertToNDCSchema(args *configuration.ConvertCommandArguments, logger *slog.Logger) error { start := time.Now() logger.Debug( - "converting the document to NDC REST schema", + "converting the document to NDC HTTP schema", slog.String("file", args.File), slog.String("config", args.Config), slog.String("output", args.Output), diff --git a/ndc-rest-schema/command/convert_test.go b/ndc-http-schema/command/convert_test.go similarity index 94% rename from ndc-rest-schema/command/convert_test.go rename to ndc-http-schema/command/convert_test.go index 2ce66a2..6706773 100644 --- a/ndc-rest-schema/command/convert_test.go +++ b/ndc-http-schema/command/convert_test.go @@ -8,8 +8,8 @@ import ( "os" "testing" - "github.com/hasura/ndc-rest/ndc-rest-schema/configuration" - "github.com/hasura/ndc-rest/ndc-rest-schema/schema" + "github.com/hasura/ndc-http/ndc-http-schema/configuration" + "github.com/hasura/ndc-http/ndc-http-schema/schema" "gotest.tools/v3/assert" ) @@ -131,7 +131,7 @@ func TestConvertToNDCSchema(t *testing.T) { t.Errorf("cannot read the output file at %s, %s", outputFilePath, err) t.FailNow() } - var output schema.NDCRestSchema + var output schema.NDCHttpSchema if err := json.Unmarshal(outputBytes, &output); err != nil { t.Errorf("cannot decode the output file json at %s: %s", outputFilePath, err) t.FailNow() @@ -145,12 +145,12 @@ func TestConvertToNDCSchema(t *testing.T) { t.Errorf("cannot read the expected file at %s: %s", outputFilePath, err) t.FailNow() } - var expectedSchema schema.NDCRestSchema + var expectedSchema schema.NDCHttpSchema if err := json.Unmarshal(expectedBytes, &expectedSchema); err != nil { t.Errorf("cannot decode the output file json at %s: %s", tc.expected, err) t.FailNow() } - assert.DeepEqual(t, expectedSchema.Settings, output.Settings) + assertDeepEqual(t, expectedSchema.Settings, output.Settings) assert.DeepEqual(t, expectedSchema.Functions, output.Functions) assert.DeepEqual(t, expectedSchema.Procedures, output.Procedures) assert.DeepEqual(t, expectedSchema.ScalarTypes, output.ScalarTypes) diff --git a/ndc-rest-schema/command/json2yaml.go b/ndc-http-schema/command/json2yaml.go similarity index 95% rename from ndc-rest-schema/command/json2yaml.go rename to ndc-http-schema/command/json2yaml.go index 5f68f8e..a306a64 100644 --- a/ndc-rest-schema/command/json2yaml.go +++ b/ndc-http-schema/command/json2yaml.go @@ -7,7 +7,7 @@ import ( "log/slog" "os" - "github.com/hasura/ndc-rest/ndc-rest-schema/utils" + "github.com/hasura/ndc-http/ndc-http-schema/utils" "gopkg.in/yaml.v3" ) diff --git a/ndc-rest-schema/command/json2yaml_test.go b/ndc-http-schema/command/json2yaml_test.go similarity index 100% rename from ndc-rest-schema/command/json2yaml_test.go rename to ndc-http-schema/command/json2yaml_test.go diff --git a/ndc-rest-schema/command/testdata/auth/config.yaml b/ndc-http-schema/command/testdata/auth/config.yaml similarity index 97% rename from ndc-rest-schema/command/testdata/auth/config.yaml rename to ndc-http-schema/command/testdata/auth/config.yaml index 1f2eabc..d84ce35 100644 --- a/ndc-rest-schema/command/testdata/auth/config.yaml +++ b/ndc-http-schema/command/testdata/auth/config.yaml @@ -8,7 +8,7 @@ forwardHeaders: concurrency: query: 1 mutation: 1 - rest: 10 + http: 10 files: - file: schema.yaml spec: ndc diff --git a/ndc-rest-schema/command/testdata/auth/expected.json b/ndc-http-schema/command/testdata/auth/expected.json similarity index 97% rename from ndc-rest-schema/command/testdata/auth/expected.json rename to ndc-http-schema/command/testdata/auth/expected.json index d08dd27..a1753a0 100644 --- a/ndc-rest-schema/command/testdata/auth/expected.json +++ b/ndc-http-schema/command/testdata/auth/expected.json @@ -86,7 +86,7 @@ "request": { "url": "/pet", "method": "get", - "type": "rest", + "type": "http", "response": { "contentType": "" } @@ -105,7 +105,7 @@ "request": { "url": "/pet/findByStatus", "method": "get", - "type": "rest", + "type": "http", "security": [ { "bearer": [] @@ -125,7 +125,7 @@ "type": "named" } }, - "rest": { + "http": { "in": "query", "schema": { "type": ["string"] @@ -146,7 +146,7 @@ "request": { "url": "/pet/retry", "method": "get", - "type": "rest", + "type": "http", "response": { "contentType": "" } @@ -225,7 +225,7 @@ "request": { "url": "/pet", "method": "post", - "type": "rest", + "type": "http", "headers": { "Content-Type": { "value": "application/json" @@ -250,7 +250,7 @@ "name": "Pet", "type": "named" }, - "rest": { + "http": { "in": "body" } } @@ -265,7 +265,7 @@ "request": { "url": "/model", "method": "post", - "type": "rest", + "type": "http", "requestBody": { "contentType": "application/json" }, diff --git a/ndc-rest-schema/command/testdata/auth/schema.yaml b/ndc-http-schema/command/testdata/auth/schema.yaml similarity index 99% rename from ndc-rest-schema/command/testdata/auth/schema.yaml rename to ndc-http-schema/command/testdata/auth/schema.yaml index d9fe12c..ed5faa1 100644 --- a/ndc-rest-schema/command/testdata/auth/schema.yaml +++ b/ndc-http-schema/command/testdata/auth/schema.yaml @@ -56,7 +56,7 @@ functions: underlying_type: name: String type: named - rest: + http: in: query schema: type: [string] @@ -102,7 +102,7 @@ procedures: type: name: Pet type: named - rest: + http: in: body description: Add a new pet to the store name: addPet diff --git a/ndc-rest-schema/command/testdata/patch/config.yaml b/ndc-http-schema/command/testdata/patch/config.yaml similarity index 98% rename from ndc-rest-schema/command/testdata/patch/config.yaml rename to ndc-http-schema/command/testdata/patch/config.yaml index e050e22..acdf985 100644 --- a/ndc-rest-schema/command/testdata/patch/config.yaml +++ b/ndc-http-schema/command/testdata/patch/config.yaml @@ -11,7 +11,7 @@ forwardHeaders: concurrency: query: 1 mutation: 1 - rest: 0 + http: 0 files: - file: ../auth/schema.yaml spec: ndc diff --git a/ndc-rest-schema/command/testdata/patch/expected.json b/ndc-http-schema/command/testdata/patch/expected.json similarity index 92% rename from ndc-rest-schema/command/testdata/patch/expected.json rename to ndc-http-schema/command/testdata/patch/expected.json index cdfd62a..4eb3fe8 100644 --- a/ndc-rest-schema/command/testdata/patch/expected.json +++ b/ndc-http-schema/command/testdata/patch/expected.json @@ -92,7 +92,7 @@ "request": { "url": "/pet", "method": "get", - "type": "rest", + "type": "http", "response": { "contentType": "" } @@ -108,12 +108,12 @@ } } }, - "restOptions": { - "description": "Execution options for REST requests to a single server", + "httpOptions": { + "description": "Execution options for HTTP requests to a single server", "type": { "type": "nullable", "underlying_type": { - "name": "RestSingleOptions", + "name": "HttpSingleOptions", "type": "named" } } @@ -129,7 +129,7 @@ "request": { "url": "/pet/findByStatus", "method": "get", - "type": "rest", + "type": "http", "security": [ { "bearer": [] @@ -150,12 +150,12 @@ } } }, - "restOptions": { - "description": "Execution options for REST requests to a single server", + "httpOptions": { + "description": "Execution options for HTTP requests to a single server", "type": { "type": "nullable", "underlying_type": { - "name": "RestSingleOptions", + "name": "HttpSingleOptions", "type": "named" } } @@ -169,7 +169,7 @@ "type": "named" } }, - "rest": { + "http": { "in": "query", "schema": { "type": ["string"] @@ -187,7 +187,7 @@ "request": { "url": "/pet/findByStatus", "method": "get", - "type": "rest", + "type": "http", "security": [ { "bearer": [] @@ -208,12 +208,12 @@ } } }, - "restOptions": { - "description": "Distributed execution options for REST requests to multiple servers", + "httpOptions": { + "description": "Distributed execution options for HTTP requests to multiple servers", "type": { "type": "nullable", "underlying_type": { - "name": "RestDistributedOptions", + "name": "HttpDistributedOptions", "type": "named" } } @@ -227,7 +227,7 @@ "type": "named" } }, - "rest": { + "http": { "in": "query", "schema": { "type": ["string"] @@ -245,7 +245,7 @@ "request": { "url": "/pet", "method": "get", - "type": "rest", + "type": "http", "response": { "contentType": "" } @@ -261,12 +261,12 @@ } } }, - "restOptions": { - "description": "Distributed execution options for REST requests to multiple servers", + "httpOptions": { + "description": "Distributed execution options for HTTP requests to multiple servers", "type": { "type": "nullable", "underlying_type": { - "name": "RestDistributedOptions", + "name": "HttpDistributedOptions", "type": "named" } } @@ -282,7 +282,7 @@ "request": { "url": "/pet/retry", "method": "get", - "type": "rest", + "type": "http", "response": { "contentType": "" } @@ -298,12 +298,12 @@ } } }, - "restOptions": { - "description": "Execution options for REST requests to a single server", + "httpOptions": { + "description": "Execution options for HTTP requests to a single server", "type": { "type": "nullable", "underlying_type": { - "name": "RestSingleOptions", + "name": "HttpSingleOptions", "type": "named" } } @@ -318,7 +318,7 @@ "request": { "url": "/pet/retry", "method": "get", - "type": "rest", + "type": "http", "response": { "contentType": "" } @@ -334,12 +334,12 @@ } } }, - "restOptions": { - "description": "Distributed execution options for REST requests to multiple servers", + "httpOptions": { + "description": "Distributed execution options for HTTP requests to multiple servers", "type": { "type": "nullable", "underlying_type": { - "name": "RestDistributedOptions", + "name": "HttpDistributedOptions", "type": "named" } } @@ -409,7 +409,7 @@ "server": { "description": "Identity of the remote server", "type": { - "name": "RestServerId", + "name": "HttpServerId", "type": "named" } } @@ -494,7 +494,7 @@ "server": { "description": "Identity of the remote server", "type": { - "name": "RestServerId", + "name": "HttpServerId", "type": "named" } } @@ -562,7 +562,7 @@ "server": { "description": "Identity of the remote server", "type": { - "name": "RestServerId", + "name": "HttpServerId", "type": "named" } } @@ -628,7 +628,7 @@ "server": { "description": "Identity of the remote server", "type": { - "name": "RestServerId", + "name": "HttpServerId", "type": "named" } } @@ -716,7 +716,7 @@ "server": { "description": "Identity of the remote server", "type": { - "name": "RestServerId", + "name": "HttpServerId", "type": "named" } } @@ -823,7 +823,7 @@ "server": { "description": "Identity of the remote server", "type": { - "name": "RestServerId", + "name": "HttpServerId", "type": "named" } } @@ -875,8 +875,8 @@ } } }, - "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", @@ -894,7 +894,7 @@ "type": "nullable", "underlying_type": { "element_type": { - "name": "RestServerId", + "name": "HttpServerId", "type": "named" }, "type": "array" @@ -903,8 +903,8 @@ } } }, - "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", @@ -912,7 +912,7 @@ "type": "nullable", "underlying_type": { "element_type": { - "name": "RestServerId", + "name": "HttpServerId", "type": "named" }, "type": "array" @@ -927,7 +927,7 @@ "request": { "url": "/pet", "method": "post", - "type": "rest", + "type": "http", "headers": { "Content-Type": { "value": "application/json" @@ -952,7 +952,7 @@ "name": "Pet", "type": "named" }, - "rest": { + "http": { "in": "body" } }, @@ -966,12 +966,12 @@ } } }, - "restOptions": { - "description": "Execution options for REST requests to a single server", + "httpOptions": { + "description": "Execution options for HTTP requests to a single server", "type": { "type": "nullable", "underlying_type": { - "name": "RestSingleOptions", + "name": "HttpSingleOptions", "type": "named" } } @@ -987,7 +987,7 @@ "request": { "url": "/pet", "method": "post", - "type": "rest", + "type": "http", "headers": { "Content-Type": { "value": "application/json" @@ -1012,7 +1012,7 @@ "name": "Pet", "type": "named" }, - "rest": { + "http": { "in": "body" } }, @@ -1026,12 +1026,12 @@ } } }, - "restOptions": { - "description": "Distributed execution options for REST requests to multiple servers", + "httpOptions": { + "description": "Distributed execution options for HTTP requests to multiple servers", "type": { "type": "nullable", "underlying_type": { - "name": "RestDistributedOptions", + "name": "HttpDistributedOptions", "type": "named" } } @@ -1047,7 +1047,7 @@ "request": { "url": "/model", "method": "post", - "type": "rest", + "type": "http", "requestBody": { "contentType": "application/json" }, @@ -1073,12 +1073,12 @@ } } }, - "restOptions": { - "description": "Execution options for REST requests to a single server", + "httpOptions": { + "description": "Execution options for HTTP requests to a single server", "type": { "type": "nullable", "underlying_type": { - "name": "RestSingleOptions", + "name": "HttpSingleOptions", "type": "named" } } @@ -1093,7 +1093,7 @@ "request": { "url": "/model", "method": "post", - "type": "rest", + "type": "http", "requestBody": { "contentType": "application/json" }, @@ -1119,12 +1119,12 @@ } } }, - "restOptions": { - "description": "Distributed execution options for REST requests to multiple servers", + "httpOptions": { + "description": "Distributed execution options for HTTP requests to multiple servers", "type": { "type": "nullable", "underlying_type": { - "name": "RestDistributedOptions", + "name": "HttpDistributedOptions", "type": "named" } } @@ -1158,7 +1158,7 @@ "type": "json" } }, - "RestServerId": { + "HttpServerId": { "aggregate_functions": {}, "comparison_operators": {}, "representation": { diff --git a/ndc-rest-schema/command/testdata/patch/patch-after.yaml b/ndc-http-schema/command/testdata/patch/patch-after.yaml similarity index 100% rename from ndc-rest-schema/command/testdata/patch/patch-after.yaml rename to ndc-http-schema/command/testdata/patch/patch-after.yaml diff --git a/ndc-rest-schema/command/testdata/patch/patch-before.yaml b/ndc-http-schema/command/testdata/patch/patch-before.yaml similarity index 100% rename from ndc-rest-schema/command/testdata/patch/patch-before.yaml rename to ndc-http-schema/command/testdata/patch/patch-before.yaml diff --git a/ndc-rest-schema/command/update.go b/ndc-http-schema/command/update.go similarity index 74% rename from ndc-rest-schema/command/update.go rename to ndc-http-schema/command/update.go index a079df2..e9aa542 100644 --- a/ndc-rest-schema/command/update.go +++ b/ndc-http-schema/command/update.go @@ -4,7 +4,7 @@ import ( "log/slog" "time" - "github.com/hasura/ndc-rest/ndc-rest-schema/configuration" + "github.com/hasura/ndc-http/ndc-http-schema/configuration" ) // UpdateCommandArguments represent input arguments of the `update` command @@ -12,10 +12,10 @@ type UpdateCommandArguments struct { Dir string `help:"The directory where the config.yaml file is present" short:"d" env:"HASURA_PLUGIN_CONNECTOR_CONTEXT_PATH" default:"."` } -// UpdateConfiguration updates the configuration for the REST connector +// UpdateConfiguration updates the configuration for the HTTP connector func UpdateConfiguration(args *UpdateCommandArguments, logger *slog.Logger) error { start := time.Now() - if err := configuration.UpdateRESTConfiguration(args.Dir, logger); err != nil { + if err := configuration.UpdateHTTPConfiguration(args.Dir, logger); err != nil { return err } diff --git a/ndc-rest-schema/command/update_test.go b/ndc-http-schema/command/update_test.go similarity index 56% rename from ndc-rest-schema/command/update_test.go rename to ndc-http-schema/command/update_test.go index 66141d4..026ee32 100644 --- a/ndc-rest-schema/command/update_test.go +++ b/ndc-http-schema/command/update_test.go @@ -9,8 +9,8 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" - "github.com/hasura/ndc-rest/ndc-rest-schema/configuration" - "github.com/hasura/ndc-rest/ndc-rest-schema/schema" + "github.com/hasura/ndc-http/ndc-http-schema/configuration" + "github.com/hasura/ndc-http/ndc-http-schema/schema" "gotest.tools/v3/assert" ) @@ -19,14 +19,14 @@ func TestUpdateCommand(t *testing.T) { Argument UpdateCommandArguments Expected string }{ - // go run ./ndc-rest-schema update -d ./ndc-rest-schema/command/testdata/patch + // go run ./ndc-http-schema update -d ./ndc-http-schema/command/testdata/patch { Argument: UpdateCommandArguments{ Dir: "testdata/patch", }, Expected: "testdata/patch/expected.json", }, - // go run ./ndc-rest-schema update -d ./ndc-rest-schema/command/testdata/auth + // go run ./ndc-http-schema update -d ./ndc-http-schema/command/testdata/auth { Argument: UpdateCommandArguments{ Dir: "testdata/auth", @@ -46,51 +46,51 @@ func TestUpdateCommand(t *testing.T) { } } -func readRuntimeSchemaFile(t *testing.T, filePath string) []configuration.NDCRestRuntimeSchema { +func readRuntimeSchemaFile(t *testing.T, filePath string) []configuration.NDCHttpRuntimeSchema { t.Helper() rawBytes, err := os.ReadFile(filePath) assert.NilError(t, err) - var result []configuration.NDCRestRuntimeSchema + var result []configuration.NDCHttpRuntimeSchema assert.NilError(t, json.Unmarshal(rawBytes, &result)) return result } -func assertSchemaEqual(t *testing.T, expectedSchemas []configuration.NDCRestRuntimeSchema, outputSchemas []configuration.NDCRestRuntimeSchema) { +func assertSchemaEqual(t *testing.T, expectedSchemas []configuration.NDCHttpRuntimeSchema, outputSchemas []configuration.NDCHttpRuntimeSchema) { t.Helper() assert.Equal(t, len(expectedSchemas), len(outputSchemas)) for i, expected := range expectedSchemas { output := outputSchemas[i] - assetDeepEqual(t, expected.Settings.Headers, output.Settings.Headers) - assetDeepEqual(t, expected.Settings.Security, output.Settings.Security) - assetDeepEqual(t, expected.Settings.SecuritySchemes, output.Settings.SecuritySchemes) - assetDeepEqual(t, expected.Settings.Version, output.Settings.Version) + assertDeepEqual(t, expected.Settings.Headers, output.Settings.Headers) + assertDeepEqual(t, expected.Settings.Security, output.Settings.Security) + assertDeepEqual(t, expected.Settings.SecuritySchemes, output.Settings.SecuritySchemes) + assertDeepEqual(t, expected.Settings.Version, output.Settings.Version) for i, server := range expected.Settings.Servers { sv := output.Settings.Servers[i] - assetDeepEqual(t, server.Headers, sv.Headers) - assetDeepEqual(t, server.ID, sv.ID) - assetDeepEqual(t, server.Security, sv.Security) - assetDeepEqual(t, server.SecuritySchemes, sv.SecuritySchemes) - assetDeepEqual(t, server.URL, sv.URL) - assetDeepEqual(t, server.TLS, sv.TLS) + assertDeepEqual(t, server.Headers, sv.Headers) + assertDeepEqual(t, server.ID, sv.ID) + assertDeepEqual(t, server.Security, sv.Security) + assertDeepEqual(t, server.SecuritySchemes, sv.SecuritySchemes) + assertDeepEqual(t, server.URL, sv.URL) + assertDeepEqual(t, server.TLS, sv.TLS) } - assetDeepEqual(t, expected.ScalarTypes, output.ScalarTypes) + assertDeepEqual(t, expected.ScalarTypes, output.ScalarTypes) objectBs, _ := json.Marshal(output.ObjectTypes) var objectTypes map[string]schema.ObjectType assert.NilError(t, json.Unmarshal(objectBs, &objectTypes)) - assetDeepEqual(t, expected.ObjectTypes, objectTypes) - assetDeepEqual(t, expected.Procedures, output.Procedures) - assetDeepEqual(t, expected.Functions, output.Functions) + assertDeepEqual(t, expected.ObjectTypes, objectTypes) + assertDeepEqual(t, expected.Procedures, output.Procedures) + assertDeepEqual(t, expected.Functions, output.Functions) } } -func assetDeepEqual(t *testing.T, expected any, reality any) { +func assertDeepEqual(t *testing.T, expected any, reality any) { t.Helper() assert.DeepEqual(t, expected, reality, - cmpopts.IgnoreUnexported(schema.ServerConfig{}, schema.NDCRestSettings{}), + cmpopts.IgnoreUnexported(schema.ServerConfig{}, schema.NDCHttpSettings{}), cmp.Exporter(func(t reflect.Type) bool { return true }), ) } diff --git a/ndc-rest-schema/config.example.yaml b/ndc-http-schema/config.example.yaml similarity index 94% rename from ndc-rest-schema/config.example.yaml rename to ndc-http-schema/config.example.yaml index b0462a5..a001316 100644 --- a/ndc-rest-schema/config.example.yaml +++ b/ndc-http-schema/config.example.yaml @@ -1,4 +1,4 @@ -# yaml-language-server: $schema=https://raw.githubusercontent.com/hasura/ndc-rest/refs/heads/main/ndc-rest-schema/jsonschema/convert-config.schema.json +# yaml-language-server: $schema=https://raw.githubusercontent.com/hasura/ndc-http/refs/heads/main/ndc-http-schema/jsonschema/convert-config.schema.json # -- File path needs to be converted. file: "" diff --git a/ndc-rest-schema/configuration/convert.go b/ndc-http-schema/configuration/convert.go similarity index 90% rename from ndc-rest-schema/configuration/convert.go rename to ndc-http-schema/configuration/convert.go index 2cef373..bfabb25 100644 --- a/ndc-rest-schema/configuration/convert.go +++ b/ndc-http-schema/configuration/convert.go @@ -6,13 +6,13 @@ import ( "fmt" "log/slog" - "github.com/hasura/ndc-rest/ndc-rest-schema/openapi" - "github.com/hasura/ndc-rest/ndc-rest-schema/schema" - "github.com/hasura/ndc-rest/ndc-rest-schema/utils" + "github.com/hasura/ndc-http/ndc-http-schema/openapi" + "github.com/hasura/ndc-http/ndc-http-schema/schema" + "github.com/hasura/ndc-http/ndc-http-schema/utils" ) -// ConvertToNDCSchema converts to NDC REST schema from config -func ConvertToNDCSchema(config *ConvertConfig, logger *slog.Logger) (*schema.NDCRestSchema, error) { +// ConvertToNDCSchema converts to NDC HTTP schema from config +func ConvertToNDCSchema(config *ConvertConfig, logger *slog.Logger) (*schema.NDCHttpSchema, error) { rawContent, err := utils.ReadFileFromPath(config.File) if err != nil { return nil, err @@ -23,7 +23,7 @@ func ConvertToNDCSchema(config *ConvertConfig, logger *slog.Logger) (*schema.NDC return nil, err } - var result *schema.NDCRestSchema + var result *schema.NDCHttpSchema var errs []error options := openapi.ConvertOptions{ MethodAlias: config.MethodAlias, @@ -53,7 +53,7 @@ func ConvertToNDCSchema(config *ConvertConfig, logger *slog.Logger) (*schema.NDC logger.Error(errors.Join(errs...).Error()) } - return utils.ApplyPatchToRestSchema(result, config.PatchAfter) + return utils.ApplyPatchToHTTPSchema(result, config.PatchAfter) } // ResolveConvertConfigArguments resolves convert config arguments diff --git a/ndc-rest-schema/configuration/schema.go b/ndc-http-schema/configuration/schema.go similarity index 85% rename from ndc-rest-schema/configuration/schema.go rename to ndc-http-schema/configuration/schema.go index 22df4c6..0e7e0ff 100644 --- a/ndc-rest-schema/configuration/schema.go +++ b/ndc-http-schema/configuration/schema.go @@ -9,15 +9,15 @@ import ( "reflect" "strconv" - rest "github.com/hasura/ndc-rest/ndc-rest-schema/schema" - restUtils "github.com/hasura/ndc-rest/ndc-rest-schema/utils" + rest "github.com/hasura/ndc-http/ndc-http-schema/schema" + restUtils "github.com/hasura/ndc-http/ndc-http-schema/utils" "github.com/hasura/ndc-sdk-go/schema" "github.com/hasura/ndc-sdk-go/utils" ) -// BuildSchemaFromConfig build NDC REST schema from the configuration -func BuildSchemaFromConfig(config *Configuration, configDir string, logger *slog.Logger) ([]NDCRestRuntimeSchema, map[string][]string) { - schemas := make([]NDCRestRuntimeSchema, len(config.Files)) +// BuildSchemaFromConfig build NDC HTTP schema from the configuration +func BuildSchemaFromConfig(config *Configuration, configDir string, logger *slog.Logger) ([]NDCHttpRuntimeSchema, map[string][]string) { + schemas := make([]NDCHttpRuntimeSchema, len(config.Files)) errors := make(map[string][]string) for i, file := range config.Files { schemaOutput, err := buildSchemaFile(config, configDir, &file, logger) @@ -28,9 +28,9 @@ func BuildSchemaFromConfig(config *Configuration, configDir string, logger *slog if schemaOutput == nil { continue } - ndcSchema := NDCRestRuntimeSchema{ + ndcSchema := NDCHttpRuntimeSchema{ Name: file.File, - NDCRestSchema: schemaOutput, + NDCHttpSchema: schemaOutput, } runtime, err := file.GetRuntimeSettings() @@ -47,7 +47,7 @@ func BuildSchemaFromConfig(config *Configuration, configDir string, logger *slog } // ReadSchemaOutputFile reads the schema output file in disk -func ReadSchemaOutputFile(configDir string, filePath string, logger *slog.Logger) ([]NDCRestRuntimeSchema, error) { +func ReadSchemaOutputFile(configDir string, filePath string, logger *slog.Logger) ([]NDCHttpRuntimeSchema, error) { if filePath == "" { return nil, nil } @@ -62,7 +62,7 @@ func ReadSchemaOutputFile(configDir string, filePath string, logger *slog.Logger return nil, fmt.Errorf("failed to read the file at %s: %w", outputFilePath, err) } - var result []NDCRestRuntimeSchema + var result []NDCHttpRuntimeSchema if err := json.Unmarshal(rawBytes, &result); err != nil { return nil, fmt.Errorf("failed to unmarshal the schema file at %s: %w", outputFilePath, err) } @@ -70,26 +70,26 @@ func ReadSchemaOutputFile(configDir string, filePath string, logger *slog.Logger return result, nil } -// MergeNDCRestSchemas merge REST schemas into a single schema object -func MergeNDCRestSchemas(config *Configuration, schemas []NDCRestRuntimeSchema) (*rest.NDCRestSchema, []NDCRestRuntimeSchema, map[string][]string) { - ndcSchema := &rest.NDCRestSchema{ +// MergeNDCHttpSchemas merge HTTP schemas into a single schema object +func MergeNDCHttpSchemas(config *Configuration, schemas []NDCHttpRuntimeSchema) (*rest.NDCHttpSchema, []NDCHttpRuntimeSchema, map[string][]string) { + ndcSchema := &rest.NDCHttpSchema{ ScalarTypes: make(schema.SchemaResponseScalarTypes), ObjectTypes: make(map[string]rest.ObjectType), Functions: make(map[string]rest.OperationInfo), Procedures: make(map[string]rest.OperationInfo), } - appliedSchemas := make([]NDCRestRuntimeSchema, len(schemas)) + appliedSchemas := make([]NDCHttpRuntimeSchema, len(schemas)) errors := make(map[string][]string) for i, item := range schemas { - if item.NDCRestSchema == nil { + if item.NDCHttpSchema == nil { errors[item.Name] = []string{fmt.Sprintf("schema of the item %d (%s) is empty", i, item.Name)} return nil, nil, errors } settings := item.Settings if settings == nil { - settings = &rest.NDCRestSettings{} + settings = &rest.NDCHttpSettings{} } else { for i, server := range settings.Servers { if server.Security.IsEmpty() { @@ -118,10 +118,10 @@ func MergeNDCRestSchemas(config *Configuration, schemas []NDCRestRuntimeSchema) } } - meta := NDCRestRuntimeSchema{ + meta := NDCHttpRuntimeSchema{ Name: item.Name, Runtime: item.Runtime, - NDCRestSchema: &rest.NDCRestSchema{ + NDCHttpSchema: &rest.NDCHttpSchema{ Settings: settings, Functions: map[string]rest.OperationInfo{}, Procedures: map[string]rest.OperationInfo{}, @@ -196,7 +196,7 @@ func MergeNDCRestSchemas(config *Configuration, schemas []NDCRestRuntimeSchema) return ndcSchema, appliedSchemas, errors } -func buildSchemaFile(config *Configuration, configDir string, configItem *ConfigItem, logger *slog.Logger) (*rest.NDCRestSchema, error) { +func buildSchemaFile(config *Configuration, configDir string, configItem *ConfigItem, logger *slog.Logger) (*rest.NDCHttpSchema, error) { if configItem.ConvertConfig.File == "" { return nil, errFilePathRequired } @@ -210,13 +210,13 @@ func buildSchemaFile(config *Configuration, configDir string, configItem *Config return nil, fmt.Errorf("the servers setting of schema %s is empty", configItem.ConvertConfig.File) } - buildRESTArguments(config, ndcSchema, configItem) + buildHTTPArguments(config, ndcSchema, configItem) buildHeadersForwardingResponse(config, ndcSchema) return ndcSchema, nil } -func buildRESTArguments(config *Configuration, restSchema *rest.NDCRestSchema, conf *ConfigItem) { +func buildHTTPArguments(config *Configuration, restSchema *rest.NDCHttpSchema, conf *ConfigItem) { if restSchema.Settings == nil || len(restSchema.Settings.Servers) < 2 { return } @@ -235,8 +235,8 @@ func buildRESTArguments(config *Configuration, restSchema *rest.NDCRestSchema, c serverScalar := schema.NewScalarType() serverScalar.Representation = schema.NewTypeRepresentationEnum(serverIDs).Encode() - restSchema.ScalarTypes[rest.RESTServerIDScalarName] = *serverScalar - restSchema.ObjectTypes[rest.RESTSingleOptionsObjectName] = singleObjectType + restSchema.ScalarTypes[rest.HTTPServerIDScalarName] = *serverScalar + restSchema.ObjectTypes[rest.HTTPSingleOptionsObjectName] = singleObjectType for _, fn := range restSchema.Functions { applyOperationInfo(config, &fn) @@ -250,14 +250,14 @@ func buildRESTArguments(config *Configuration, restSchema *rest.NDCRestSchema, c return } - restSchema.ObjectTypes[rest.RESTDistributedOptionsObjectName] = distributedObjectType + restSchema.ObjectTypes[rest.HTTPDistributedOptionsObjectName] = distributedObjectType restSchema.ObjectTypes[rest.DistributedErrorObjectName] = rest.ObjectType{ Description: utils.ToPtr("The error response of the remote request"), Fields: map[string]rest.ObjectField{ "server": { ObjectField: schema.ObjectField{ Description: utils.ToPtr("Identity of the remote server"), - Type: schema.NewNamedType(rest.RESTServerIDScalarName).Encode(), + Type: schema.NewNamedType(rest.HTTPServerIDScalarName).Encode(), }, }, "message": { @@ -303,7 +303,7 @@ func buildRESTArguments(config *Configuration, restSchema *rest.NDCRestSchema, c } } -func buildHeadersForwardingResponse(config *Configuration, restSchema *rest.NDCRestSchema) { +func buildHeadersForwardingResponse(config *Configuration, restSchema *rest.NDCHttpSchema) { if !config.ForwardHeaders.Enabled { return } @@ -331,7 +331,7 @@ func buildHeadersForwardingResponse(config *Configuration, restSchema *rest.NDCR } func applyOperationInfo(config *Configuration, info *rest.OperationInfo) { - info.Arguments[rest.RESTOptionsArgumentName] = restSingleOptionsArgument + info.Arguments[rest.HTTPOptionsArgumentName] = httpSingleOptionsArgument if config.ForwardHeaders.Enabled && config.ForwardHeaders.ArgumentField != nil { info.Arguments[*config.ForwardHeaders.ArgumentField] = headersArguments } @@ -340,21 +340,21 @@ func applyOperationInfo(config *Configuration, info *rest.OperationInfo) { func cloneDistributedArguments(arguments map[string]rest.ArgumentInfo) map[string]rest.ArgumentInfo { result := map[string]rest.ArgumentInfo{} for k, v := range arguments { - if k != rest.RESTOptionsArgumentName { + if k != rest.HTTPOptionsArgumentName { result[k] = v } } - result[rest.RESTOptionsArgumentName] = rest.ArgumentInfo{ + result[rest.HTTPOptionsArgumentName] = rest.ArgumentInfo{ ArgumentInfo: schema.ArgumentInfo{ Description: distributedObjectType.Description, - Type: schema.NewNullableNamedType(rest.RESTDistributedOptionsObjectName).Encode(), + Type: schema.NewNullableNamedType(rest.HTTPDistributedOptionsObjectName).Encode(), }, } return result } -func buildDistributedResultObjectType(restSchema *rest.NDCRestSchema, operationName string, underlyingType schema.Type) string { +func buildDistributedResultObjectType(restSchema *rest.NDCHttpSchema, operationName string, underlyingType schema.Type) string { distResultType := restUtils.StringSliceToPascalCase([]string{operationName, "Result"}) distResultDataType := distResultType + "Data" @@ -364,7 +364,7 @@ func buildDistributedResultObjectType(restSchema *rest.NDCRestSchema, operationN "server": { ObjectField: schema.ObjectField{ Description: utils.ToPtr("Identity of the remote server"), - Type: schema.NewNamedType(rest.RESTServerIDScalarName).Encode(), + Type: schema.NewNamedType(rest.HTTPServerIDScalarName).Encode(), }, }, "data": { @@ -409,14 +409,10 @@ func validateRequestSchema(req *rest.Request, defaultMethod string) (*rest.Reque req.Method = defaultMethod } - if req.Type == "" { - req.Type = rest.RequestTypeREST - } - return req, nil } -func createHeaderForwardingResponseTypes(restSchema *rest.NDCRestSchema, operationName string, resultType schema.Type, settings *ForwardResponseHeadersSettings) schema.Type { +func createHeaderForwardingResponseTypes(restSchema *rest.NDCHttpSchema, operationName string, resultType schema.Type, settings *ForwardResponseHeadersSettings) schema.Type { objectName := restUtils.ToPascalCase(operationName) + "HeadersResponse" objectType := rest.ObjectType{ Fields: map[string]rest.ObjectField{ diff --git a/ndc-rest-schema/configuration/types.go b/ndc-http-schema/configuration/types.go similarity index 93% rename from ndc-rest-schema/configuration/types.go rename to ndc-http-schema/configuration/types.go index 72b18d4..bffcd51 100644 --- a/ndc-rest-schema/configuration/types.go +++ b/ndc-http-schema/configuration/types.go @@ -6,8 +6,8 @@ import ( "fmt" "regexp" - rest "github.com/hasura/ndc-rest/ndc-rest-schema/schema" - restUtils "github.com/hasura/ndc-rest/ndc-rest-schema/utils" + rest "github.com/hasura/ndc-http/ndc-http-schema/schema" + restUtils "github.com/hasura/ndc-http/ndc-http-schema/utils" "github.com/hasura/ndc-sdk-go/schema" "github.com/hasura/ndc-sdk-go/utils" ) @@ -36,7 +36,7 @@ type ConcurrencySettings struct { // Maximum number of concurrent executions if there are many mutation operations. Mutation uint `json:"mutation" yaml:"mutation"` // Maximum number of concurrent requests to remote servers (distribution mode). - REST uint `json:"rest" yaml:"rest"` + HTTP uint `json:"http" yaml:"http"` } // ForwardHeadersSettings hold settings of header forwarding from and to Hasura engine @@ -220,11 +220,11 @@ type ConvertConfig struct { Output string `json:"output,omitempty" yaml:"output,omitempty"` } -// NDCRestRuntimeSchema wraps NDCRestSchema with runtime settings -type NDCRestRuntimeSchema struct { +// NDCHttpRuntimeSchema wraps NDCHttpSchema with runtime settings +type NDCHttpRuntimeSchema struct { Name string `json:"name" yaml:"name"` Runtime rest.RuntimeSettings `json:"-" yaml:"-"` - *rest.NDCRestSchema + *rest.NDCHttpSchema } // ConvertCommandArguments represent available command arguments for the convert command @@ -245,27 +245,27 @@ type ConvertCommandArguments struct { PatchAfter []string `help:"Patch files to be applied into the input file after converting"` } -// the object type of REST execution options for single server +// the object type of HTTP execution options for single server var singleObjectType = rest.ObjectType{ - Description: utils.ToPtr("Execution options for REST requests to a single server"), + Description: utils.ToPtr("Execution options for HTTP requests to a single server"), Fields: map[string]rest.ObjectField{ "servers": { ObjectField: schema.ObjectField{ Description: utils.ToPtr("Specify remote servers to receive the request. If there are many server IDs the server is selected randomly"), - Type: schema.NewNullableType(schema.NewArrayType(schema.NewNamedType(rest.RESTServerIDScalarName))).Encode(), + Type: schema.NewNullableType(schema.NewArrayType(schema.NewNamedType(rest.HTTPServerIDScalarName))).Encode(), }, }, }, } -// the object type of REST execution options for distributed servers +// the object type of HTTP execution options for distributed servers var distributedObjectType rest.ObjectType = rest.ObjectType{ - Description: utils.ToPtr("Distributed execution options for REST requests to multiple servers"), + Description: utils.ToPtr("Distributed execution options for HTTP requests to multiple servers"), Fields: map[string]rest.ObjectField{ "servers": { ObjectField: schema.ObjectField{ Description: utils.ToPtr("Specify remote servers to receive the request"), - Type: schema.NewNullableType(schema.NewArrayType(schema.NewNamedType(rest.RESTServerIDScalarName))).Encode(), + Type: schema.NewNullableType(schema.NewArrayType(schema.NewNamedType(rest.HTTPServerIDScalarName))).Encode(), }, }, "parallel": { @@ -284,9 +284,9 @@ var headersArguments = rest.ArgumentInfo{ }, } -var restSingleOptionsArgument = rest.ArgumentInfo{ +var httpSingleOptionsArgument = rest.ArgumentInfo{ ArgumentInfo: schema.ArgumentInfo{ Description: singleObjectType.Description, - Type: schema.NewNullableNamedType(rest.RESTSingleOptionsObjectName).Encode(), + Type: schema.NewNullableNamedType(rest.HTTPSingleOptionsObjectName).Encode(), }, } diff --git a/ndc-rest-schema/configuration/update.go b/ndc-http-schema/configuration/update.go similarity index 83% rename from ndc-rest-schema/configuration/update.go rename to ndc-http-schema/configuration/update.go index d6d0e8f..471b48c 100644 --- a/ndc-rest-schema/configuration/update.go +++ b/ndc-http-schema/configuration/update.go @@ -8,12 +8,12 @@ import ( "os" "path/filepath" - "github.com/hasura/ndc-rest/ndc-rest-schema/utils" + "github.com/hasura/ndc-http/ndc-http-schema/utils" "gopkg.in/yaml.v3" ) -// UpdateRESTConfiguration validates and updates the REST configuration -func UpdateRESTConfiguration(configurationDir string, logger *slog.Logger) error { +// UpdateHTTPConfiguration validates and updates the HTTP configuration +func UpdateHTTPConfiguration(configurationDir string, logger *slog.Logger) error { config, err := ReadConfigurationFile(configurationDir) if err != nil { return err @@ -27,11 +27,11 @@ func UpdateRESTConfiguration(configurationDir string, logger *slog.Logger) error } } - _, validatedSchemas, errs := MergeNDCRestSchemas(config, schemas) + _, validatedSchemas, errs := MergeNDCHttpSchemas(config, schemas) if len(errs) > 0 { printSchemaValidationError(logger, errs) if validatedSchemas == nil || config.Strict { - return errors.New("invalid rest schema") + return errors.New("invalid http schema") } } @@ -44,7 +44,7 @@ func UpdateRESTConfiguration(configurationDir string, logger *slog.Logger) error } func printSchemaValidationError(logger *slog.Logger, errors map[string][]string) { - logger.Error("errors happen when validating NDC REST schemas", slog.Any("errors", errors)) + logger.Error("errors happen when validating NDC HTTP schemas", slog.Any("errors", errors)) } // ReadConfigurationFile reads and decodes the configuration file from the configuration directory diff --git a/ndc-rest-schema/go.mod b/ndc-http-schema/go.mod similarity index 96% rename from ndc-rest-schema/go.mod rename to ndc-http-schema/go.mod index 16b4bf1..6af562f 100644 --- a/ndc-rest-schema/go.mod +++ b/ndc-http-schema/go.mod @@ -1,4 +1,4 @@ -module github.com/hasura/ndc-rest/ndc-rest-schema +module github.com/hasura/ndc-http/ndc-http-schema go 1.23.0 diff --git a/ndc-rest-schema/go.sum b/ndc-http-schema/go.sum similarity index 100% rename from ndc-rest-schema/go.sum rename to ndc-http-schema/go.sum diff --git a/ndc-rest-schema/jsonschema/configuration.schema.json b/ndc-http-schema/jsonschema/configuration.schema.json similarity index 96% rename from ndc-rest-schema/jsonschema/configuration.schema.json rename to ndc-http-schema/jsonschema/configuration.schema.json index 408922c..3a22ec4 100644 --- a/ndc-rest-schema/jsonschema/configuration.schema.json +++ b/ndc-http-schema/jsonschema/configuration.schema.json @@ -1,21 +1,21 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://github.com/hasura/ndc-rest/ndc-rest-schema/configuration/configuration", + "$id": "https://github.com/hasura/ndc-http/ndc-http-schema/configuration/configuration", "$ref": "#/$defs/Configuration", "$defs": { "ConcurrencySettings": { "properties": { "query": { "type": "integer", - "description": "Maximum number of concurrent executions if there are many query variables. Zero means unlimited." + "description": "Maximum number of concurrent executions if there are many query variables." }, "mutation": { "type": "integer", - "description": "Maximum number of concurrent executions if there are many mutation operations. Zero means unlimited." + "description": "Maximum number of concurrent executions if there are many mutation operations." }, - "rest": { + "http": { "type": "integer", - "description": "Maximum number of concurrent requests to remote servers (distribution mode). Zero means unlimited." + "description": "Maximum number of concurrent requests to remote servers (distribution mode)." } }, "additionalProperties": false, @@ -23,7 +23,7 @@ "required": [ "query", "mutation", - "rest" + "http" ], "description": "ConcurrencySettings represent settings for concurrent webhook executions to remote servers." }, diff --git a/ndc-rest-schema/jsonschema/convert-config.schema.json b/ndc-http-schema/jsonschema/convert-config.schema.json similarity index 97% rename from ndc-rest-schema/jsonschema/convert-config.schema.json rename to ndc-http-schema/jsonschema/convert-config.schema.json index e751b73..38960d4 100644 --- a/ndc-rest-schema/jsonschema/convert-config.schema.json +++ b/ndc-http-schema/jsonschema/convert-config.schema.json @@ -1,6 +1,6 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://github.com/hasura/ndc-rest/ndc-rest-schema/configuration/convert-config", + "$id": "https://github.com/hasura/ndc-http/ndc-http-schema/configuration/convert-config", "$ref": "#/$defs/ConvertConfig", "$defs": { "ConvertConfig": { diff --git a/ndc-rest-schema/jsonschema/generator.go b/ndc-http-schema/jsonschema/generator.go similarity index 70% rename from ndc-rest-schema/jsonschema/generator.go rename to ndc-http-schema/jsonschema/generator.go index 888dbb2..bc1fce5 100644 --- a/ndc-rest-schema/jsonschema/generator.go +++ b/ndc-http-schema/jsonschema/generator.go @@ -5,8 +5,8 @@ import ( "fmt" "os" - "github.com/hasura/ndc-rest/ndc-rest-schema/configuration" - "github.com/hasura/ndc-rest/ndc-rest-schema/schema" + "github.com/hasura/ndc-http/ndc-http-schema/configuration" + "github.com/hasura/ndc-http/ndc-http-schema/schema" "github.com/invopop/jsonschema" ) @@ -14,8 +14,8 @@ func main() { if err := jsonSchemaConvertConfig(); err != nil { panic(fmt.Errorf("failed to write jsonschema for ConvertConfig: %w", err)) } - if err := jsonSchemaNdcRESTSchema(); err != nil { - panic(fmt.Errorf("failed to write jsonschema for NDCRestSchema: %w", err)) + if err := jsonSchemaNDCHttpSchema(); err != nil { + panic(fmt.Errorf("failed to write jsonschema for NDCHttpSchema: %w", err)) } if err := jsonSchemaConnectorConfiguration(); err != nil { panic(fmt.Errorf("failed to write jsonschema for Configuration: %w", err)) @@ -24,7 +24,7 @@ func main() { func jsonSchemaConvertConfig() error { r := new(jsonschema.Reflector) - if err := r.AddGoComments("github.com/hasura/ndc-rest/ndc-rest-schema/configuration", "../configuration"); err != nil { + if err := r.AddGoComments("github.com/hasura/ndc-http/ndc-http-schema/configuration", "../configuration"); err != nil { return err } reflectSchema := r.Reflect(&configuration.ConvertConfig{}) @@ -39,7 +39,7 @@ func jsonSchemaConvertConfig() error { func jsonSchemaConnectorConfiguration() error { r := new(jsonschema.Reflector) - if err := r.AddGoComments("github.com/hasura/ndc-rest/ndc-rest-schema/configuration", "../configuration"); err != nil { + if err := r.AddGoComments("github.com/hasura/ndc-http/ndc-http-schema/configuration", "../configuration"); err != nil { return err } reflectSchema := r.Reflect(&configuration.Configuration{}) @@ -52,17 +52,17 @@ func jsonSchemaConnectorConfiguration() error { return os.WriteFile("configuration.schema.json", schemaBytes, 0644) } -func jsonSchemaNdcRESTSchema() error { +func jsonSchemaNDCHttpSchema() error { r := new(jsonschema.Reflector) - if err := r.AddGoComments("github.com/hasura/ndc-rest/ndc-rest-schema/schema", "../schema"); err != nil { + if err := r.AddGoComments("github.com/hasura/ndc-http/ndc-http-schema/schema", "../schema"); err != nil { return err } - reflectSchema := r.Reflect(&schema.NDCRestSchema{}) + reflectSchema := r.Reflect(&schema.NDCHttpSchema{}) schemaBytes, err := json.MarshalIndent(reflectSchema, "", " ") if err != nil { return err } - return os.WriteFile("ndc-rest-schema.schema.json", schemaBytes, 0644) + return os.WriteFile("ndc-http-schema.schema.json", schemaBytes, 0644) } diff --git a/ndc-http-schema/jsonschema/ndc-http-schema.schema.json b/ndc-http-schema/jsonschema/ndc-http-schema.schema.json new file mode 100644 index 0000000..1cdce69 --- /dev/null +++ b/ndc-http-schema/jsonschema/ndc-http-schema.schema.json @@ -0,0 +1,763 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://github.com/hasura/ndc-http/ndc-http-schema/schema/ndc-http-schema", + "$ref": "#/$defs/NDCHttpSchema", + "$defs": { + "AggregateFunctionDefinition": { + "properties": { + "result_type": { + "$ref": "#/$defs/Type" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "result_type" + ] + }, + "ArgumentInfo": { + "properties": { + "description": { + "type": "string" + }, + "type": { + "$ref": "#/$defs/Type" + }, + "http": { + "$ref": "#/$defs/RequestParameter", + "description": "The request parameter information of the HTTP request" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "type" + ], + "description": "ArgumentInfo the information of HTTP request argument" + }, + "AuthSecurities": { + "items": { + "$ref": "#/$defs/AuthSecurity" + }, + "type": "array", + "description": "AuthSecurities wraps list of security requirements with helpers" + }, + "AuthSecurity": { + "additionalProperties": { + "items": { + "type": "string" + }, + "type": "array" + }, + "type": "object", + "description": "AuthSecurity wraps the raw security requirement with helpers" + }, + "ComparisonOperatorDefinition": { + "type": "object" + }, + "EncodingObject": { + "properties": { + "style": { + "$ref": "#/$defs/ParameterEncodingStyle", + "description": "Describes how a specific property value will be serialized depending on its type.\nSee Parameter Object for details on the style property.\nThe behavior follows the same values as query parameters, including default values.\nThis property SHALL be ignored if the request body media type is not application/x-www-form-urlencoded or multipart/form-data.\nIf a value is explicitly defined, then the value of contentType (implicit or explicit) SHALL be ignored" + }, + "explode": { + "type": "boolean", + "description": "When this is true, property values of type array or object generate separate parameters for each value of the array, or key-value-pair of the map.\nFor other types of properties this property has no effect. When style is form, the default value is true. For all other styles, the default value is false.\nThis property SHALL be ignored if the request body media type is not application/x-www-form-urlencoded or multipart/form-data.\nIf a value is explicitly defined, then the value of contentType (implicit or explicit) SHALL be ignored" + }, + "allowReserved": { + "type": "boolean", + "description": "By default, reserved characters :/?#[]@!$\u0026'()*+,;= in form field values within application/x-www-form-urlencoded bodies are percent-encoded when sent.\nAllowReserved allows these characters to be sent as is:" + }, + "contentType": { + "items": { + "type": "string" + }, + "type": "array", + "description": "For more complex scenarios, such as nested arrays or JSON in form data, use the contentType keyword to specify the media type for encoding the value of a complex field." + }, + "headers": { + "additionalProperties": { + "$ref": "#/$defs/RequestParameter" + }, + "type": "object", + "description": "A map allowing additional information to be provided as headers, for example Content-Disposition.\nContent-Type is described separately and SHALL be ignored in this section.\nThis property SHALL be ignored if the request body media type is not a multipart." + } + }, + "additionalProperties": false, + "type": "object", + "description": "EncodingObject represents the Encoding Object that contains serialization strategy for application/x-www-form-urlencoded\n\n[Encoding Object]: https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#encoding-object" + }, + "EnvBool": { + "anyOf": [ + { + "required": [ + "value" + ], + "title": "value" + }, + { + "required": [ + "env" + ], + "title": "env" + } + ], + "properties": { + "value": { + "type": "boolean" + }, + "env": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" + }, + "EnvInt": { + "anyOf": [ + { + "required": [ + "value" + ], + "title": "value" + }, + { + "required": [ + "env" + ], + "title": "env" + } + ], + "properties": { + "value": { + "type": "integer" + }, + "env": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" + }, + "EnvString": { + "anyOf": [ + { + "required": [ + "value" + ], + "title": "value" + }, + { + "required": [ + "env" + ], + "title": "env" + } + ], + "properties": { + "value": { + "type": "string" + }, + "env": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object" + }, + "NDCHttpSchema": { + "properties": { + "$schema": { + "type": "string" + }, + "settings": { + "$ref": "#/$defs/NDCHttpSettings" + }, + "functions": { + "additionalProperties": { + "$ref": "#/$defs/OperationInfo" + }, + "type": "object", + "description": "Functions (i.e. collections which return a single column and row)" + }, + "object_types": { + "additionalProperties": { + "$ref": "#/$defs/ObjectType" + }, + "type": "object", + "description": "A list of object types which can be used as the types of arguments, or return\ntypes of procedures. Names should not overlap with scalar type names." + }, + "procedures": { + "additionalProperties": { + "$ref": "#/$defs/OperationInfo" + }, + "type": "object", + "description": "Procedures which are available for execution as part of mutations" + }, + "scalar_types": { + "$ref": "#/$defs/SchemaResponseScalarTypes", + "description": "A list of scalar types which will be used as the types of collection columns" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "functions", + "object_types", + "procedures", + "scalar_types" + ], + "description": "NDCHttpSchema extends the [NDC SchemaResponse] with OpenAPI HTTP information" + }, + "NDCHttpSettings": { + "properties": { + "servers": { + "items": { + "$ref": "#/$defs/ServerConfig" + }, + "type": "array" + }, + "headers": { + "additionalProperties": { + "$ref": "#/$defs/EnvString" + }, + "type": "object" + }, + "securitySchemes": { + "additionalProperties": { + "$ref": "#/$defs/SecurityScheme" + }, + "type": "object" + }, + "security": { + "$ref": "#/$defs/AuthSecurities" + }, + "version": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "servers" + ], + "description": "NDCHttpSettings represent global settings of the HTTP API, including base URL, headers, etc..." + }, + "ObjectField": { + "properties": { + "arguments": { + "$ref": "#/$defs/ObjectFieldArguments" + }, + "description": { + "type": "string" + }, + "type": { + "$ref": "#/$defs/Type" + }, + "http": { + "$ref": "#/$defs/TypeSchema", + "description": "The field schema information of the HTTP request" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "type" + ], + "description": "ObjectField defined on this object type" + }, + "ObjectFieldArguments": { + "additionalProperties": { + "$ref": "#/$defs/ArgumentInfo" + }, + "type": "object" + }, + "ObjectType": { + "properties": { + "description": { + "type": "string", + "description": "Description of this type" + }, + "fields": { + "additionalProperties": { + "$ref": "#/$defs/ObjectField" + }, + "type": "object", + "description": "Fields defined on this object type" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "fields" + ], + "description": "ObjectType represents the object type of http schema" + }, + "OperationInfo": { + "properties": { + "request": { + "$ref": "#/$defs/Request" + }, + "arguments": { + "additionalProperties": { + "$ref": "#/$defs/ArgumentInfo" + }, + "type": "object", + "description": "Any arguments that this collection requires" + }, + "description": { + "type": "string", + "description": "Column description" + }, + "result_type": { + "$ref": "#/$defs/Type", + "description": "The name of the result type" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "request", + "arguments", + "result_type" + ], + "description": "OperationInfo extends connector command operation with OpenAPI HTTP information" + }, + "ParameterEncodingStyle": { + "type": "string", + "enum": [ + "simple", + "label", + "matrix", + "form", + "spaceDelimited", + "pipeDelimited", + "deepObject" + ] + }, + "ParameterLocation": { + "type": "string", + "enum": [ + "query", + "header", + "path", + "cookie", + "body", + "formData" + ] + }, + "Request": { + "properties": { + "url": { + "type": "string" + }, + "method": { + "type": "string", + "enum": [ + "get", + "post", + "put", + "patch", + "delete" + ] + }, + "headers": { + "additionalProperties": { + "$ref": "#/$defs/EnvString" + }, + "type": "object" + }, + "security": { + "$ref": "#/$defs/AuthSecurities" + }, + "servers": { + "items": { + "$ref": "#/$defs/ServerConfig" + }, + "type": "array" + }, + "requestBody": { + "$ref": "#/$defs/RequestBody" + }, + "response": { + "$ref": "#/$defs/Response" + }, + "timeout": { + "type": "integer" + }, + "retry": { + "$ref": "#/$defs/RetryPolicy" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "response" + ], + "description": "Request represents the HTTP request information of the webhook" + }, + "RequestBody": { + "properties": { + "contentType": { + "type": "string" + }, + "encoding": { + "additionalProperties": { + "$ref": "#/$defs/EncodingObject" + }, + "type": "object" + } + }, + "additionalProperties": false, + "type": "object", + "description": "RequestBody defines flexible request body with content types" + }, + "RequestParameter": { + "properties": { + "style": { + "$ref": "#/$defs/ParameterEncodingStyle", + "description": "Describes how a specific property value will be serialized depending on its type.\nSee Parameter Object for details on the style property.\nThe behavior follows the same values as query parameters, including default values.\nThis property SHALL be ignored if the request body media type is not application/x-www-form-urlencoded or multipart/form-data.\nIf a value is explicitly defined, then the value of contentType (implicit or explicit) SHALL be ignored" + }, + "explode": { + "type": "boolean", + "description": "When this is true, property values of type array or object generate separate parameters for each value of the array, or key-value-pair of the map.\nFor other types of properties this property has no effect. When style is form, the default value is true. For all other styles, the default value is false.\nThis property SHALL be ignored if the request body media type is not application/x-www-form-urlencoded or multipart/form-data.\nIf a value is explicitly defined, then the value of contentType (implicit or explicit) SHALL be ignored" + }, + "allowReserved": { + "type": "boolean", + "description": "By default, reserved characters :/?#[]@!$\u0026'()*+,;= in form field values within application/x-www-form-urlencoded bodies are percent-encoded when sent.\nAllowReserved allows these characters to be sent as is:" + }, + "contentType": { + "items": { + "type": "string" + }, + "type": "array", + "description": "For more complex scenarios, such as nested arrays or JSON in form data, use the contentType keyword to specify the media type for encoding the value of a complex field." + }, + "headers": { + "additionalProperties": { + "$ref": "#/$defs/RequestParameter" + }, + "type": "object", + "description": "A map allowing additional information to be provided as headers, for example Content-Disposition.\nContent-Type is described separately and SHALL be ignored in this section.\nThis property SHALL be ignored if the request body media type is not a multipart." + }, + "name": { + "type": "string" + }, + "argumentName": { + "type": "string" + }, + "in": { + "$ref": "#/$defs/ParameterLocation" + }, + "schema": { + "$ref": "#/$defs/TypeSchema" + } + }, + "additionalProperties": false, + "type": "object", + "description": "RequestParameter represents an HTTP request parameter" + }, + "Response": { + "properties": { + "contentType": { + "type": "string" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "contentType" + ] + }, + "RetryPolicy": { + "properties": { + "times": { + "type": "integer", + "description": "Number of retry times" + }, + "delay": { + "type": "integer", + "description": "Delay retry delay in milliseconds" + }, + "httpStatus": { + "items": { + "type": "integer" + }, + "type": "array", + "description": "HTTPStatus retries if the remote service returns one of these http status" + } + }, + "additionalProperties": false, + "type": "object", + "description": "RetryPolicy represents the retry policy of request" + }, + "ScalarType": { + "properties": { + "aggregate_functions": { + "$ref": "#/$defs/ScalarTypeAggregateFunctions" + }, + "comparison_operators": { + "additionalProperties": { + "$ref": "#/$defs/ComparisonOperatorDefinition" + }, + "type": "object" + }, + "representation": { + "$ref": "#/$defs/TypeRepresentation" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "aggregate_functions", + "comparison_operators" + ] + }, + "ScalarTypeAggregateFunctions": { + "additionalProperties": { + "$ref": "#/$defs/AggregateFunctionDefinition" + }, + "type": "object" + }, + "SchemaResponseScalarTypes": { + "additionalProperties": { + "$ref": "#/$defs/ScalarType" + }, + "type": "object" + }, + "SecurityScheme": { + "oneOf": [ + { + "properties": { + "type": { + "type": "string", + "enum": [ + "apiKey" + ] + }, + "value": { + "type": "string" + }, + "in": { + "type": "string", + "enum": [ + "header", + "query", + "cookie" + ] + }, + "name": { + "type": "string" + } + }, + "type": "object", + "required": [ + "type", + "value", + "in", + "name" + ] + }, + { + "properties": { + "type": { + "type": "string", + "enum": [ + "http" + ] + }, + "value": { + "type": "string" + }, + "header": { + "type": "string" + }, + "scheme": { + "type": "string" + } + }, + "type": "object", + "required": [ + "type", + "value", + "header", + "scheme" + ] + }, + { + "properties": { + "type": { + "type": "string", + "enum": [ + "oauth2" + ] + }, + "flows": { + "additionalProperties": true, + "type": "object" + } + }, + "type": "object", + "required": [ + "type", + "flows" + ] + }, + { + "properties": { + "type": { + "type": "string", + "enum": [ + "openIdConnect" + ] + }, + "openIdConnectUrl": { + "type": "string" + } + }, + "type": "object", + "required": [ + "type", + "openIdConnectUrl" + ] + } + ] + }, + "ServerConfig": { + "properties": { + "url": { + "$ref": "#/$defs/EnvString" + }, + "id": { + "type": "string" + }, + "headers": { + "additionalProperties": { + "$ref": "#/$defs/EnvString" + }, + "type": "object" + }, + "securitySchemes": { + "additionalProperties": { + "$ref": "#/$defs/SecurityScheme" + }, + "type": "object" + }, + "security": { + "$ref": "#/$defs/AuthSecurities" + }, + "tls": { + "$ref": "#/$defs/TLSConfig" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "url" + ], + "description": "ServerConfig contains server configurations" + }, + "TLSConfig": { + "properties": { + "certFile": { + "$ref": "#/$defs/EnvString", + "description": "Path to the TLS cert to use for TLS required connections." + }, + "certPem": { + "$ref": "#/$defs/EnvString", + "description": "Alternative to cert_file. Provide the certificate contents as a string instead of a filepath." + }, + "keyFile": { + "$ref": "#/$defs/EnvString", + "description": "Path to the TLS key to use for TLS required connections." + }, + "keyPem": { + "$ref": "#/$defs/EnvString", + "description": "Alternative to key_file. Provide the key contents as a string instead of a filepath." + }, + "caFile": { + "$ref": "#/$defs/EnvString", + "description": "Path to the CA cert. For a client this verifies the server certificate. For a server this verifies client certificates.\nIf empty uses system root CA." + }, + "caPem": { + "$ref": "#/$defs/EnvString", + "description": "Alternative to ca_file. Provide the CA cert contents as a string instead of a filepath." + }, + "insecureSkipVerify": { + "$ref": "#/$defs/EnvBool", + "description": "Additionally you can configure TLS to be enabled but skip verifying the server's certificate chain." + }, + "includeSystemCACertsPool": { + "$ref": "#/$defs/EnvBool", + "description": "Whether to load the system certificate authorities pool alongside the certificate authority." + }, + "minVersion": { + "$ref": "#/$defs/EnvString", + "description": "Minimum acceptable TLS version." + }, + "maxVersion": { + "$ref": "#/$defs/EnvString", + "description": "Maximum acceptable TLS version." + }, + "cipherSuites": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Explicit cipher suites can be set. If left blank, a safe default list is used.\nSee https://go.dev/src/crypto/tls/cipher_suites.go for a list of supported cipher suites." + }, + "reloadInterval": { + "$ref": "#/$defs/EnvInt", + "description": "Specifies the duration after which the certificate will be reloaded. If not set, it will never be reloaded.\nThe interval unit is minute" + } + }, + "additionalProperties": false, + "type": "object", + "description": "TLSConfig represents the transport layer security (LTS) configuration for the mutualTLS authentication" + }, + "Type": { + "type": "object" + }, + "TypeRepresentation": { + "type": "object" + }, + "TypeSchema": { + "properties": { + "type": { + "items": { + "type": "string" + }, + "type": "array" + }, + "format": { + "type": "string" + }, + "pattern": { + "type": "string" + }, + "maximum": { + "type": "number" + }, + "minimum": { + "type": "number" + }, + "maxLength": { + "type": "integer" + }, + "minLength": { + "type": "integer" + }, + "items": { + "$ref": "#/$defs/TypeSchema" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "type" + ], + "description": "TypeSchema represents a serializable object of OpenAPI schema that is used for validation" + } + } +} \ No newline at end of file diff --git a/ndc-rest-schema/jsonschema/ndc-rest-schema.schema.json b/ndc-http-schema/jsonschema/ndc-rest-schema.schema.json similarity index 87% rename from ndc-rest-schema/jsonschema/ndc-rest-schema.schema.json rename to ndc-http-schema/jsonschema/ndc-rest-schema.schema.json index 68fc49b..1256ef2 100644 --- a/ndc-rest-schema/jsonschema/ndc-rest-schema.schema.json +++ b/ndc-http-schema/jsonschema/ndc-rest-schema.schema.json @@ -1,7 +1,7 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://github.com/hasura/ndc-rest/ndc-rest-schema/schema/ndc-rest-schema", - "$ref": "#/$defs/NDCRestSchema", + "$id": "https://github.com/hasura/ndc-http/ndc-http-schema/schema/ndc-http-schema", + "$ref": "#/$defs/NDCHttpSchema", "$defs": { "AggregateFunctionDefinition": { "properties": { @@ -11,9 +11,7 @@ }, "additionalProperties": false, "type": "object", - "required": [ - "result_type" - ] + "required": ["result_type"] }, "ArgumentInfo": { "properties": { @@ -23,17 +21,15 @@ "type": { "$ref": "#/$defs/Type" }, - "rest": { + "http": { "$ref": "#/$defs/RequestParameter", - "description": "The request parameter information of the REST request" + "description": "The request parameter information of the HTTP request" } }, "additionalProperties": false, "type": "object", - "required": [ - "type" - ], - "description": "ArgumentInfo the information of REST request argument" + "required": ["type"], + "description": "ArgumentInfo the information of HTTP request argument" }, "AuthSecurities": { "items": { @@ -91,15 +87,11 @@ "EnvBool": { "anyOf": [ { - "required": [ - "value" - ], + "required": ["value"], "title": "value" }, { - "required": [ - "env" - ], + "required": ["env"], "title": "env" } ], @@ -117,15 +109,11 @@ "EnvInt": { "anyOf": [ { - "required": [ - "value" - ], + "required": ["value"], "title": "value" }, { - "required": [ - "env" - ], + "required": ["env"], "title": "env" } ], @@ -143,15 +131,11 @@ "EnvString": { "anyOf": [ { - "required": [ - "value" - ], + "required": ["value"], "title": "value" }, { - "required": [ - "env" - ], + "required": ["env"], "title": "env" } ], @@ -166,13 +150,13 @@ "additionalProperties": false, "type": "object" }, - "NDCRestSchema": { + "NDCHttpSchema": { "properties": { "$schema": { "type": "string" }, "settings": { - "$ref": "#/$defs/NDCRestSettings" + "$ref": "#/$defs/NDCHttpSettings" }, "functions": { "additionalProperties": { @@ -202,15 +186,10 @@ }, "additionalProperties": false, "type": "object", - "required": [ - "functions", - "object_types", - "procedures", - "scalar_types" - ], - "description": "NDCRestSchema extends the [NDC SchemaResponse] with OpenAPI REST information" + "required": ["functions", "object_types", "procedures", "scalar_types"], + "description": "NDCHttpSchema extends the [NDC SchemaResponse] with OpenAPI HTTP information" }, - "NDCRestSettings": { + "NDCHttpSettings": { "properties": { "servers": { "items": { @@ -239,10 +218,8 @@ }, "additionalProperties": false, "type": "object", - "required": [ - "servers" - ], - "description": "NDCRestSettings represent global settings of the REST API, including base URL, headers, etc..." + "required": ["servers"], + "description": "NDCHttpSettings represent global settings of the HTTP API, including base URL, headers, etc..." }, "ObjectField": { "properties": { @@ -255,16 +232,14 @@ "type": { "$ref": "#/$defs/Type" }, - "rest": { + "http": { "$ref": "#/$defs/TypeSchema", - "description": "The field schema information of the REST request" + "description": "The field schema information of the HTTP request" } }, "additionalProperties": false, "type": "object", - "required": [ - "type" - ], + "required": ["type"], "description": "ObjectField defined on this object type" }, "ObjectFieldArguments": { @@ -289,10 +264,8 @@ }, "additionalProperties": false, "type": "object", - "required": [ - "fields" - ], - "description": "ObjectType represents the object type of rest schema" + "required": ["fields"], + "description": "ObjectType represents the object type of http schema" }, "OperationInfo": { "properties": { @@ -317,12 +290,8 @@ }, "additionalProperties": false, "type": "object", - "required": [ - "request", - "arguments", - "result_type" - ], - "description": "OperationInfo extends connector command operation with OpenAPI REST information" + "required": ["request", "arguments", "result_type"], + "description": "OperationInfo extends connector command operation with OpenAPI HTTP information" }, "ParameterEncodingStyle": { "type": "string", @@ -338,14 +307,7 @@ }, "ParameterLocation": { "type": "string", - "enum": [ - "query", - "header", - "path", - "cookie", - "body", - "formData" - ] + "enum": ["query", "header", "path", "cookie", "body", "formData"] }, "Request": { "properties": { @@ -354,13 +316,7 @@ }, "method": { "type": "string", - "enum": [ - "get", - "post", - "put", - "patch", - "delete" - ] + "enum": ["get", "post", "put", "patch", "delete"] }, "type": { "type": "string" @@ -395,9 +351,7 @@ }, "additionalProperties": false, "type": "object", - "required": [ - "response" - ], + "required": ["response"], "description": "Request represents the HTTP request information of the webhook" }, "RequestBody": { @@ -469,9 +423,7 @@ }, "additionalProperties": false, "type": "object", - "required": [ - "contentType" - ] + "required": ["contentType"] }, "RetryPolicy": { "properties": { @@ -512,10 +464,7 @@ }, "additionalProperties": false, "type": "object", - "required": [ - "aggregate_functions", - "comparison_operators" - ] + "required": ["aggregate_functions", "comparison_operators"] }, "ScalarTypeAggregateFunctions": { "additionalProperties": { @@ -535,40 +484,27 @@ "properties": { "type": { "type": "string", - "enum": [ - "apiKey" - ] + "enum": ["apiKey"] }, "value": { "type": "string" }, "in": { "type": "string", - "enum": [ - "header", - "query", - "cookie" - ] + "enum": ["header", "query", "cookie"] }, "name": { "type": "string" } }, "type": "object", - "required": [ - "type", - "value", - "in", - "name" - ] + "required": ["type", "value", "in", "name"] }, { "properties": { "type": { "type": "string", - "enum": [ - "http" - ] + "enum": ["http"] }, "value": { "type": "string" @@ -581,20 +517,13 @@ } }, "type": "object", - "required": [ - "type", - "value", - "header", - "scheme" - ] + "required": ["type", "value", "header", "scheme"] }, { "properties": { "type": { "type": "string", - "enum": [ - "oauth2" - ] + "enum": ["oauth2"] }, "flows": { "additionalProperties": true, @@ -602,28 +531,20 @@ } }, "type": "object", - "required": [ - "type", - "flows" - ] + "required": ["type", "flows"] }, { "properties": { "type": { "type": "string", - "enum": [ - "openIdConnect" - ] + "enum": ["openIdConnect"] }, "openIdConnectUrl": { "type": "string" } }, "type": "object", - "required": [ - "type", - "openIdConnectUrl" - ] + "required": ["type", "openIdConnectUrl"] } ] }, @@ -656,9 +577,7 @@ }, "additionalProperties": false, "type": "object", - "required": [ - "url" - ], + "required": ["url"], "description": "ServerConfig contains server configurations" }, "TLSConfig": { @@ -757,10 +676,8 @@ }, "additionalProperties": false, "type": "object", - "required": [ - "type" - ], + "required": ["type"], "description": "TypeSchema represents a serializable object of OpenAPI schema that is used for validation" } } -} \ No newline at end of file +} diff --git a/ndc-rest-schema/main.go b/ndc-http-schema/main.go similarity index 83% rename from ndc-rest-schema/main.go rename to ndc-http-schema/main.go index b66928a..682fa2b 100644 --- a/ndc-rest-schema/main.go +++ b/ndc-http-schema/main.go @@ -7,17 +7,17 @@ import ( "strings" "github.com/alecthomas/kong" - "github.com/hasura/ndc-rest/ndc-rest-schema/command" - "github.com/hasura/ndc-rest/ndc-rest-schema/configuration" - "github.com/hasura/ndc-rest/ndc-rest-schema/version" + "github.com/hasura/ndc-http/ndc-http-schema/command" + "github.com/hasura/ndc-http/ndc-http-schema/configuration" + "github.com/hasura/ndc-http/ndc-http-schema/version" "github.com/lmittmann/tint" ) var cli struct { LogLevel string `default:"info" enum:"debug,info,warn,error" help:"Log level."` - Update command.UpdateCommandArguments `cmd:"" help:"Update REST connector configuration"` - Convert configuration.ConvertCommandArguments `cmd:"" help:"Convert API spec to NDC schema. For example:\n ndc-rest-schema convert -f petstore.yaml -o petstore.json"` - Json2Yaml command.Json2YamlCommandArguments `cmd:"" help:"Convert JSON file to YAML. For example:\n ndc-rest-schema json2yaml -f petstore.json -o petstore.yaml" name:"json2yaml"` + Update command.UpdateCommandArguments `cmd:"" help:"Update HTTP connector configuration"` + Convert configuration.ConvertCommandArguments `cmd:"" help:"Convert API spec to NDC schema. For example:\n ndc-http-schema convert -f petstore.yaml -o petstore.json"` + Json2Yaml command.Json2YamlCommandArguments `cmd:"" help:"Convert JSON file to YAML. For example:\n ndc-http-schema json2yaml -f petstore.json -o petstore.yaml" name:"json2yaml"` Version struct{} `cmd:"" help:"Print the CLI version."` } diff --git a/ndc-rest-schema/openapi/internal/ndc.go b/ndc-http-schema/openapi/internal/ndc.go similarity index 100% rename from ndc-rest-schema/openapi/internal/ndc.go rename to ndc-http-schema/openapi/internal/ndc.go diff --git a/ndc-rest-schema/openapi/internal/oas2.go b/ndc-http-schema/openapi/internal/oas2.go similarity index 97% rename from ndc-rest-schema/openapi/internal/oas2.go rename to ndc-http-schema/openapi/internal/oas2.go index 187cc1e..fa7a2c3 100644 --- a/ndc-rest-schema/openapi/internal/oas2.go +++ b/ndc-http-schema/openapi/internal/oas2.go @@ -7,8 +7,8 @@ import ( "slices" "strings" - rest "github.com/hasura/ndc-rest/ndc-rest-schema/schema" - "github.com/hasura/ndc-rest/ndc-rest-schema/utils" + rest "github.com/hasura/ndc-http/ndc-http-schema/schema" + "github.com/hasura/ndc-http/ndc-http-schema/utils" "github.com/hasura/ndc-sdk-go/schema" sdkUtils "github.com/hasura/ndc-sdk-go/utils" "github.com/pb33f/libopenapi" @@ -21,12 +21,12 @@ import ( type OAS2Builder struct { *ConvertOptions - schema *rest.NDCRestSchema + schema *rest.NDCHttpSchema typeUsageCounter TypeUsageCounter } // NewOAS2Builder creates an OAS3Builder instance -func NewOAS2Builder(schema *rest.NDCRestSchema, options ConvertOptions) *OAS2Builder { +func NewOAS2Builder(schema *rest.NDCHttpSchema, options ConvertOptions) *OAS2Builder { builder := &OAS2Builder{ schema: schema, typeUsageCounter: TypeUsageCounter{}, @@ -36,8 +36,8 @@ func NewOAS2Builder(schema *rest.NDCRestSchema, options ConvertOptions) *OAS2Bui return builder } -// Schema returns the inner NDC REST schema -func (oc *OAS2Builder) Schema() *rest.NDCRestSchema { +// Schema returns the inner NDC HTTP schema +func (oc *OAS2Builder) Schema() *rest.NDCHttpSchema { return oc.schema } @@ -335,7 +335,7 @@ func (oc *OAS2Builder) getSchemaType(typeSchema *base.Schema, apiPath string, fi ObjectField: schema.ObjectField{ Type: propType.Encode(), }, - Rest: propApiSchema, + HTTP: propApiSchema, } if propApiSchema.Description != "" { objField.Description = &propApiSchema.Description diff --git a/ndc-rest-schema/openapi/internal/oas2_operation.go b/ndc-http-schema/openapi/internal/oas2_operation.go similarity index 96% rename from ndc-rest-schema/openapi/internal/oas2_operation.go rename to ndc-http-schema/openapi/internal/oas2_operation.go index a42bbd9..6511ba9 100644 --- a/ndc-rest-schema/openapi/internal/oas2_operation.go +++ b/ndc-http-schema/openapi/internal/oas2_operation.go @@ -7,8 +7,8 @@ import ( "strconv" "strings" - rest "github.com/hasura/ndc-rest/ndc-rest-schema/schema" - "github.com/hasura/ndc-rest/ndc-rest-schema/utils" + rest "github.com/hasura/ndc-http/ndc-http-schema/schema" + "github.com/hasura/ndc-http/ndc-http-schema/utils" "github.com/hasura/ndc-sdk-go/schema" v2 "github.com/pb33f/libopenapi/datamodel/high/v2" ) @@ -25,7 +25,7 @@ func newOAS2OperationBuilder(builder *OAS2Builder) *oas2OperationBuilder { } } -// BuildFunction build a REST NDC function information from OpenAPI v2 operation +// BuildFunction build a HTTP NDC function information from OpenAPI v2 operation func (oc *oas2OperationBuilder) BuildFunction(pathKey string, operation *v2.Operation) (*rest.OperationInfo, string, error) { if operation == nil { return nil, "", nil @@ -85,7 +85,7 @@ func (oc *oas2OperationBuilder) BuildFunction(pathKey string, operation *v2.Oper return &function, funcName, nil } -// BuildProcedure build a REST NDC function information from OpenAPI v2 operation +// BuildProcedure build a HTTP NDC function information from OpenAPI v2 operation func (oc *oas2OperationBuilder) BuildProcedure(pathKey string, method string, operation *v2.Operation) (*rest.OperationInfo, string, error) { if operation == nil { return nil, "", nil @@ -235,7 +235,7 @@ func (oc *oas2OperationBuilder) convertParameters(operation *v2.Operation, apiPa switch paramLocation { case rest.InBody: - argument.Rest = &rest.RequestParameter{ + argument.HTTP = &rest.RequestParameter{ In: rest.InBody, Schema: typeSchema, } @@ -250,11 +250,11 @@ func (oc *oas2OperationBuilder) convertParameters(operation *v2.Operation, apiPa Type: argument.Type, Description: argument.Description, }, - Rest: typeSchema, + HTTP: typeSchema, } } default: - argument.Rest = &rest.RequestParameter{ + argument.HTTP = &rest.RequestParameter{ Name: paramName, In: paramLocation, Schema: typeSchema, @@ -274,7 +274,7 @@ func (oc *oas2OperationBuilder) convertParameters(operation *v2.Operation, apiPa Type: schema.NewNamedType(bodyName).Encode(), Description: &desc, }, - Rest: &rest.RequestParameter{ + HTTP: &rest.RequestParameter{ In: rest.InFormData, Schema: &formData, }, diff --git a/ndc-rest-schema/openapi/internal/oas3.go b/ndc-http-schema/openapi/internal/oas3.go similarity index 97% rename from ndc-rest-schema/openapi/internal/oas3.go rename to ndc-http-schema/openapi/internal/oas3.go index 533ff31..b063a9f 100644 --- a/ndc-rest-schema/openapi/internal/oas3.go +++ b/ndc-http-schema/openapi/internal/oas3.go @@ -5,8 +5,8 @@ import ( "log/slog" "strings" - rest "github.com/hasura/ndc-rest/ndc-rest-schema/schema" - "github.com/hasura/ndc-rest/ndc-rest-schema/utils" + rest "github.com/hasura/ndc-http/ndc-http-schema/schema" + "github.com/hasura/ndc-http/ndc-http-schema/utils" "github.com/hasura/ndc-sdk-go/schema" sdkUtils "github.com/hasura/ndc-sdk-go/utils" "github.com/pb33f/libopenapi" @@ -19,7 +19,7 @@ import ( type OAS3Builder struct { *ConvertOptions - schema *rest.NDCRestSchema + schema *rest.NDCHttpSchema // stores prebuilt and evaluating information of component schema types. // some undefined schema types aren't stored in either object nor scalar, // or self-reference types that haven't added into the object_types map yet. @@ -36,7 +36,7 @@ type SchemaInfoCache struct { } // NewOAS3Builder creates an OAS3Builder instance -func NewOAS3Builder(schema *rest.NDCRestSchema, options ConvertOptions) *OAS3Builder { +func NewOAS3Builder(schema *rest.NDCHttpSchema, options ConvertOptions) *OAS3Builder { builder := &OAS3Builder{ schema: schema, schemaCache: make(map[string]SchemaInfoCache), @@ -47,8 +47,8 @@ func NewOAS3Builder(schema *rest.NDCRestSchema, options ConvertOptions) *OAS3Bui return builder } -// Schema returns the inner NDC REST schema -func (oc *OAS3Builder) Schema() *rest.NDCRestSchema { +// Schema returns the inner NDC HTTP schema +func (oc *OAS3Builder) Schema() *rest.NDCHttpSchema { return oc.schema } @@ -379,7 +379,7 @@ func (oc *OAS3Builder) populateWriteSchemaType(schemaType schema.Type) (schema.T Description: field.Description, Type: ut, }, - Rest: field.Rest, + HTTP: field.HTTP, } if isInput { hasWriteField = true diff --git a/ndc-rest-schema/openapi/internal/oas3_operation.go b/ndc-http-schema/openapi/internal/oas3_operation.go similarity index 97% rename from ndc-rest-schema/openapi/internal/oas3_operation.go rename to ndc-http-schema/openapi/internal/oas3_operation.go index b7453e1..4fb2a88 100644 --- a/ndc-rest-schema/openapi/internal/oas3_operation.go +++ b/ndc-http-schema/openapi/internal/oas3_operation.go @@ -7,8 +7,8 @@ import ( "strings" "time" - rest "github.com/hasura/ndc-rest/ndc-rest-schema/schema" - "github.com/hasura/ndc-rest/ndc-rest-schema/utils" + rest "github.com/hasura/ndc-http/ndc-http-schema/schema" + "github.com/hasura/ndc-http/ndc-http-schema/utils" "github.com/hasura/ndc-sdk-go/schema" v3 "github.com/pb33f/libopenapi/datamodel/high/v3" ) @@ -29,7 +29,7 @@ func newOAS3OperationBuilder(builder *OAS3Builder, pathKey string, method string } } -// BuildFunction build a REST NDC function information from OpenAPI v3 operation +// BuildFunction build a HTTP NDC function information from OpenAPI v3 operation func (oc *oas3OperationBuilder) BuildFunction(itemGet *v3.Operation) (*rest.OperationInfo, string, error) { start := time.Now() funcName := itemGet.OperationId @@ -132,7 +132,7 @@ func (oc *oas3OperationBuilder) BuildProcedure(operation *v3.Operation) (*rest.O Description: &description, Type: schemaType.Encode(), }, - Rest: &rest.RequestParameter{ + HTTP: &rest.RequestParameter{ In: rest.InBody, }, } @@ -202,7 +202,7 @@ func (oc *oas3OperationBuilder) convertParameters(params []*v3.Parameter, apiPat ArgumentInfo: schema.ArgumentInfo{ Type: schemaType.Encode(), }, - Rest: &rest.RequestParameter{ + HTTP: &rest.RequestParameter{ Name: paramName, In: paramLocation, Schema: apiSchema, @@ -322,7 +322,7 @@ func (oc *oas3OperationBuilder) convertRequestBody(reqBody *v3.RequestBody, apiP item.Headers[key] = headerParam oc.Arguments[argumentName] = rest.ArgumentInfo{ ArgumentInfo: argument, - Rest: &headerParam, + HTTP: &headerParam, } } } diff --git a/ndc-rest-schema/openapi/internal/oas3_schema.go b/ndc-http-schema/openapi/internal/oas3_schema.go similarity index 98% rename from ndc-rest-schema/openapi/internal/oas3_schema.go rename to ndc-http-schema/openapi/internal/oas3_schema.go index 4ba4319..ac824f7 100644 --- a/ndc-rest-schema/openapi/internal/oas3_schema.go +++ b/ndc-http-schema/openapi/internal/oas3_schema.go @@ -8,8 +8,8 @@ import ( "strconv" "strings" - rest "github.com/hasura/ndc-rest/ndc-rest-schema/schema" - "github.com/hasura/ndc-rest/ndc-rest-schema/utils" + rest "github.com/hasura/ndc-http/ndc-http-schema/schema" + "github.com/hasura/ndc-http/ndc-http-schema/utils" "github.com/hasura/ndc-sdk-go/schema" "github.com/pb33f/libopenapi/datamodel/high/base" ) @@ -200,7 +200,7 @@ func (oc *oas3SchemaBuilder) getSchemaType(typeSchema *base.Schema, fieldPaths [ ObjectField: schema.ObjectField{ Type: propType.Encode(), }, - Rest: propApiSchema, + HTTP: propApiSchema, } if propApiSchema == nil { propApiSchema = &rest.TypeSchema{} diff --git a/ndc-rest-schema/openapi/internal/types.go b/ndc-http-schema/openapi/internal/types.go similarity index 98% rename from ndc-rest-schema/openapi/internal/types.go rename to ndc-http-schema/openapi/internal/types.go index 83014dd..dae78a2 100644 --- a/ndc-rest-schema/openapi/internal/types.go +++ b/ndc-http-schema/openapi/internal/types.go @@ -5,7 +5,7 @@ import ( "log/slog" "regexp" - rest "github.com/hasura/ndc-rest/ndc-rest-schema/schema" + rest "github.com/hasura/ndc-http/ndc-http-schema/schema" "github.com/hasura/ndc-sdk-go/schema" ) diff --git a/ndc-rest-schema/openapi/internal/utils.go b/ndc-http-schema/openapi/internal/utils.go similarity index 96% rename from ndc-rest-schema/openapi/internal/utils.go rename to ndc-http-schema/openapi/internal/utils.go index e34b7c6..29fe56d 100644 --- a/ndc-rest-schema/openapi/internal/utils.go +++ b/ndc-http-schema/openapi/internal/utils.go @@ -6,8 +6,8 @@ import ( "slices" "strings" - rest "github.com/hasura/ndc-rest/ndc-rest-schema/schema" - "github.com/hasura/ndc-rest/ndc-rest-schema/utils" + rest "github.com/hasura/ndc-http/ndc-http-schema/schema" + "github.com/hasura/ndc-http/ndc-http-schema/utils" "github.com/hasura/ndc-sdk-go/schema" "github.com/pb33f/libopenapi/datamodel/high/base" "gopkg.in/yaml.v3" @@ -48,7 +48,7 @@ func getSchemaRefTypeNameV3(name string) string { return result[1] } -func getScalarFromType(sm *rest.NDCRestSchema, names []string, format string, enumNodes []*yaml.Node, apiPath string, fieldPaths []string) string { +func getScalarFromType(sm *rest.NDCHttpSchema, names []string, format string, enumNodes []*yaml.Node, apiPath string, fieldPaths []string) string { var scalarName string var scalarType *schema.ScalarType @@ -174,7 +174,7 @@ func getScalarFromType(sm *rest.NDCRestSchema, names []string, format string, en return scalarName } -func canSetEnumToSchema(sm *rest.NDCRestSchema, scalarName string, enums []string) bool { +func canSetEnumToSchema(sm *rest.NDCHttpSchema, scalarName string, enums []string) bool { existedScalar, ok := sm.ScalarTypes[scalarName] if !ok { return true @@ -329,7 +329,7 @@ func evalSchemaProxiesSlice(schemaProxies []*base.SchemaProxy, location rest.Par return results, nil, nullable } -func cleanUnusedSchemaTypes(schema *rest.NDCRestSchema, usageCounter *TypeUsageCounter) { +func cleanUnusedSchemaTypes(schema *rest.NDCHttpSchema, usageCounter *TypeUsageCounter) { for key := range schema.ObjectTypes { cleanUnusedObjectType(schema, usageCounter, key) } @@ -341,7 +341,7 @@ func cleanUnusedSchemaTypes(schema *rest.NDCRestSchema, usageCounter *TypeUsageC } // recursively clean unused objects as well as their inner properties -func cleanUnusedObjectType(schema *rest.NDCRestSchema, usageCounter *TypeUsageCounter, key string) { +func cleanUnusedObjectType(schema *rest.NDCHttpSchema, usageCounter *TypeUsageCounter, key string) { object, ok := schema.ObjectTypes[key] if !ok { return diff --git a/ndc-rest-schema/openapi/oas2.go b/ndc-http-schema/openapi/oas2.go similarity index 72% rename from ndc-rest-schema/openapi/oas2.go rename to ndc-http-schema/openapi/oas2.go index 1ea1a0b..13002d7 100644 --- a/ndc-rest-schema/openapi/oas2.go +++ b/ndc-http-schema/openapi/oas2.go @@ -3,13 +3,13 @@ package openapi import ( "errors" - "github.com/hasura/ndc-rest/ndc-rest-schema/openapi/internal" - rest "github.com/hasura/ndc-rest/ndc-rest-schema/schema" + "github.com/hasura/ndc-http/ndc-http-schema/openapi/internal" + rest "github.com/hasura/ndc-http/ndc-http-schema/schema" "github.com/pb33f/libopenapi" ) -// OpenAPIv2ToNDCSchema converts OpenAPI v2 JSON bytes to NDC REST schema -func OpenAPIv2ToNDCSchema(input []byte, options ConvertOptions) (*rest.NDCRestSchema, []error) { +// OpenAPIv2ToNDCSchema converts OpenAPI v2 JSON bytes to NDC HTTP schema +func OpenAPIv2ToNDCSchema(input []byte, options ConvertOptions) (*rest.NDCHttpSchema, []error) { document, err := libopenapi.NewDocument(input) if err != nil { return nil, []error{err} @@ -25,7 +25,7 @@ func OpenAPIv2ToNDCSchema(input []byte, options ConvertOptions) (*rest.NDCRestSc return nil, append(errs, errors.New("there is no API to be converted")) } - converter := internal.NewOAS2Builder(rest.NewNDCRestSchema(), internal.ConvertOptions(options)) + converter := internal.NewOAS2Builder(rest.NewNDCHttpSchema(), internal.ConvertOptions(options)) if err := converter.BuildDocumentModel(docModel); err != nil { return nil, append(errs, err) } diff --git a/ndc-rest-schema/openapi/oas2_test.go b/ndc-http-schema/openapi/oas2_test.go similarity index 71% rename from ndc-rest-schema/openapi/oas2_test.go rename to ndc-http-schema/openapi/oas2_test.go index d079308..ea4eb02 100644 --- a/ndc-rest-schema/openapi/oas2_test.go +++ b/ndc-http-schema/openapi/oas2_test.go @@ -6,7 +6,7 @@ import ( "os" "testing" - rest "github.com/hasura/ndc-rest/ndc-rest-schema/schema" + rest "github.com/hasura/ndc-http/ndc-http-schema/schema" "github.com/hasura/ndc-sdk-go/schema" "gotest.tools/v3/assert" ) @@ -19,8 +19,8 @@ func TestOpenAPIv2ToRESTSchema(t *testing.T) { Expected string Schema string }{ - // go run ./ndc-rest-schema convert -f ./ndc-rest-schema/openapi/testdata/jsonplaceholder/swagger.json -o ./ndc-rest-schema/openapi/testdata/jsonplaceholder/expected.json --spec oas2 --trim-prefix /v1 - // go run ./ndc-rest-schema convert -f ./ndc-rest-schema/openapi/testdata/jsonplaceholder/swagger.json -o ./ndc-rest-schema/openapi/testdata/jsonplaceholder/schema.json --pure --spec oas2 --trim-prefix /v1 + // go run ./ndc-http-schema convert -f ./ndc-http-schema/openapi/testdata/jsonplaceholder/swagger.json -o ./ndc-http-schema/openapi/testdata/jsonplaceholder/expected.json --spec oas2 --trim-prefix /v1 + // go run ./ndc-http-schema convert -f ./ndc-http-schema/openapi/testdata/jsonplaceholder/swagger.json -o ./ndc-http-schema/openapi/testdata/jsonplaceholder/schema.json --pure --spec oas2 --trim-prefix /v1 { Name: "jsonplaceholder", Source: "testdata/jsonplaceholder/swagger.json", @@ -30,16 +30,16 @@ func TestOpenAPIv2ToRESTSchema(t *testing.T) { TrimPrefix: "/v1", }, }, - // go run ./ndc-rest-schema convert -f ./ndc-rest-schema/openapi/testdata/petstore2/swagger.json -o ./ndc-rest-schema/openapi/testdata/petstore2/expected.json --spec oas2 - // go run ./ndc-rest-schema convert -f ./ndc-rest-schema/openapi/testdata/petstore2/swagger.json -o ./ndc-rest-schema/openapi/testdata/petstore2/schema.json --pure --spec oas2 + // go run ./ndc-http-schema convert -f ./ndc-http-schema/openapi/testdata/petstore2/swagger.json -o ./ndc-http-schema/openapi/testdata/petstore2/expected.json --spec oas2 + // go run ./ndc-http-schema convert -f ./ndc-http-schema/openapi/testdata/petstore2/swagger.json -o ./ndc-http-schema/openapi/testdata/petstore2/schema.json --pure --spec oas2 { Name: "petstore2", Source: "testdata/petstore2/swagger.json", Expected: "testdata/petstore2/expected.json", Schema: "testdata/petstore2/schema.json", }, - // go run ./ndc-rest-schema convert -f ./ndc-rest-schema/openapi/testdata/prefix2/source.json -o ./ndc-rest-schema/openapi/testdata/prefix2/expected_single_word.json --spec oas2 --prefix hasura - // go run ./ndc-rest-schema convert -f ./ndc-rest-schema/openapi/testdata/prefix2/source.json -o ./ndc-rest-schema/openapi/testdata/prefix2/expected_single_word.schema.json --pure --spec oas2 --prefix hasura + // go run ./ndc-http-schema convert -f ./ndc-http-schema/openapi/testdata/prefix2/source.json -o ./ndc-http-schema/openapi/testdata/prefix2/expected_single_word.json --spec oas2 --prefix hasura + // go run ./ndc-http-schema convert -f ./ndc-http-schema/openapi/testdata/prefix2/source.json -o ./ndc-http-schema/openapi/testdata/prefix2/expected_single_word.schema.json --pure --spec oas2 --prefix hasura { Name: "prefix2_single_word", Source: "testdata/prefix2/source.json", @@ -49,8 +49,8 @@ func TestOpenAPIv2ToRESTSchema(t *testing.T) { Prefix: "hasura", }, }, - // go run ./ndc-rest-schema convert -f ./ndc-rest-schema/openapi/testdata/prefix2/source.json -o ./ndc-rest-schema/openapi/testdata/prefix2/expected_multi_words.json --spec oas2 --prefix hasura_mock_json - // go run ./ndc-rest-schema convert -f ./ndc-rest-schema/openapi/testdata/prefix2/source.json -o ./ndc-rest-schema/openapi/testdata/prefix2/expected_multi_words.schema.json --pure --spec oas2 --prefix hasura_mock_json + // go run ./ndc-http-schema convert -f ./ndc-http-schema/openapi/testdata/prefix2/source.json -o ./ndc-http-schema/openapi/testdata/prefix2/expected_multi_words.json --spec oas2 --prefix hasura_mock_json + // go run ./ndc-http-schema convert -f ./ndc-http-schema/openapi/testdata/prefix2/source.json -o ./ndc-http-schema/openapi/testdata/prefix2/expected_multi_words.schema.json --pure --spec oas2 --prefix hasura_mock_json { Name: "prefix2_single_word", Source: "testdata/prefix2/source.json", @@ -69,7 +69,7 @@ func TestOpenAPIv2ToRESTSchema(t *testing.T) { expectedBytes, err := os.ReadFile(tc.Expected) assert.NilError(t, err) - var expected rest.NDCRestSchema + var expected rest.NDCHttpSchema assert.NilError(t, json.Unmarshal(expectedBytes, &expected)) output, errs := OpenAPIv2ToNDCSchema(sourceBytes, tc.Options) @@ -89,7 +89,7 @@ func TestOpenAPIv2ToRESTSchema(t *testing.T) { }) } -func assertConnectorSchema(t *testing.T, schemaPath string, output *rest.NDCRestSchema) { +func assertConnectorSchema(t *testing.T, schemaPath string, output *rest.NDCHttpSchema) { t.Helper() if schemaPath == "" { return @@ -99,5 +99,5 @@ func assertConnectorSchema(t *testing.T, schemaPath string, output *rest.NDCRest var expectedSchema schema.SchemaResponse assert.NilError(t, json.Unmarshal(schemaBytes, &expectedSchema)) outputSchema := output.ToSchemaResponse() - assetDeepEqual(t, expectedSchema, *outputSchema) + assertDeepEqual(t, expectedSchema, *outputSchema) } diff --git a/ndc-rest-schema/openapi/oas3.go b/ndc-http-schema/openapi/oas3.go similarity index 73% rename from ndc-rest-schema/openapi/oas3.go rename to ndc-http-schema/openapi/oas3.go index c41f653..f3ab378 100644 --- a/ndc-rest-schema/openapi/oas3.go +++ b/ndc-http-schema/openapi/oas3.go @@ -3,15 +3,15 @@ package openapi import ( "errors" - "github.com/hasura/ndc-rest/ndc-rest-schema/openapi/internal" - rest "github.com/hasura/ndc-rest/ndc-rest-schema/schema" + "github.com/hasura/ndc-http/ndc-http-schema/openapi/internal" + rest "github.com/hasura/ndc-http/ndc-http-schema/schema" "github.com/pb33f/libopenapi" ) type ConvertOptions internal.ConvertOptions -// OpenAPIv3ToNDCSchema converts OpenAPI v3 JSON bytes to NDC REST schema -func OpenAPIv3ToNDCSchema(input []byte, options ConvertOptions) (*rest.NDCRestSchema, []error) { +// OpenAPIv3ToNDCSchema converts OpenAPI v3 JSON bytes to NDC HTTP schema +func OpenAPIv3ToNDCSchema(input []byte, options ConvertOptions) (*rest.NDCHttpSchema, []error) { document, err := libopenapi.NewDocument(input) if err != nil { return nil, []error{err} @@ -27,7 +27,7 @@ func OpenAPIv3ToNDCSchema(input []byte, options ConvertOptions) (*rest.NDCRestSc return nil, append(errs, errors.New("there is no API to be converted")) } - converter := internal.NewOAS3Builder(rest.NewNDCRestSchema(), internal.ConvertOptions(options)) + converter := internal.NewOAS3Builder(rest.NewNDCHttpSchema(), internal.ConvertOptions(options)) if err := converter.BuildDocumentModel(docModel); err != nil { return nil, append(errs, err) } diff --git a/ndc-rest-schema/openapi/oas3_test.go b/ndc-http-schema/openapi/oas3_test.go similarity index 58% rename from ndc-rest-schema/openapi/oas3_test.go rename to ndc-http-schema/openapi/oas3_test.go index c8b4c9a..02a9fac 100644 --- a/ndc-rest-schema/openapi/oas3_test.go +++ b/ndc-http-schema/openapi/oas3_test.go @@ -9,7 +9,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" - "github.com/hasura/ndc-rest/ndc-rest-schema/schema" + "github.com/hasura/ndc-http/ndc-http-schema/schema" "gotest.tools/v3/assert" ) @@ -22,8 +22,8 @@ func TestOpenAPIv3ToRESTSchema(t *testing.T) { Schema string Options ConvertOptions }{ - // go run ./ndc-rest-schema convert -f ./ndc-rest-schema/openapi/testdata/petstore3/source.json -o ./ndc-rest-schema/openapi/testdata/petstore3/expected.json --trim-prefix /v1 --spec openapi3 --env-prefix PET_STORE - // go run ./ndc-rest-schema convert -f ./ndc-rest-schema/openapi/testdata/petstore3/source.json -o ./ndc-rest-schema/openapi/testdata/petstore3/schema.json --pure --trim-prefix /v1 --spec openapi3 --env-prefix PET_STORE + // go run ./ndc-http-schema convert -f ./ndc-http-schema/openapi/testdata/petstore3/source.json -o ./ndc-http-schema/openapi/testdata/petstore3/expected.json --trim-prefix /v1 --spec openapi3 --env-prefix PET_STORE + // go run ./ndc-http-schema convert -f ./ndc-http-schema/openapi/testdata/petstore3/source.json -o ./ndc-http-schema/openapi/testdata/petstore3/schema.json --pure --trim-prefix /v1 --spec openapi3 --env-prefix PET_STORE { Name: "petstore3", Source: "testdata/petstore3/source.json", @@ -34,8 +34,8 @@ func TestOpenAPIv3ToRESTSchema(t *testing.T) { EnvPrefix: "PET_STORE", }, }, - // go run ./ndc-rest-schema convert -f ./ndc-rest-schema/openapi/testdata/onesignal/source.json -o ./ndc-rest-schema/openapi/testdata/onesignal/expected.json --spec openapi3 - // go run ./ndc-rest-schema convert -f ./ndc-rest-schema/openapi/testdata/onesignal/source.json -o ./ndc-rest-schema/openapi/testdata/onesignal/schema.json --pure --spec openapi3 + // go run ./ndc-http-schema convert -f ./ndc-http-schema/openapi/testdata/onesignal/source.json -o ./ndc-http-schema/openapi/testdata/onesignal/expected.json --spec openapi3 + // go run ./ndc-http-schema convert -f ./ndc-http-schema/openapi/testdata/onesignal/source.json -o ./ndc-http-schema/openapi/testdata/onesignal/schema.json --pure --spec openapi3 { Name: "onesignal", Source: "testdata/onesignal/source.json", @@ -43,8 +43,8 @@ func TestOpenAPIv3ToRESTSchema(t *testing.T) { Schema: "testdata/onesignal/schema.json", Options: ConvertOptions{}, }, - // go run ./ndc-rest-schema convert -f ./ndc-rest-schema/openapi/testdata/openai/source.json -o ./ndc-rest-schema/openapi/testdata/openai/expected.json --spec openapi3 - // go run ./ndc-rest-schema convert -f ./ndc-rest-schema/openapi/testdata/openai/source.json -o ./ndc-rest-schema/openapi/testdata/openai/schema.json --pure --spec openapi3 + // go run ./ndc-http-schema convert -f ./ndc-http-schema/openapi/testdata/openai/source.json -o ./ndc-http-schema/openapi/testdata/openai/expected.json --spec openapi3 + // go run ./ndc-http-schema convert -f ./ndc-http-schema/openapi/testdata/openai/source.json -o ./ndc-http-schema/openapi/testdata/openai/schema.json --pure --spec openapi3 { Name: "openai", Source: "testdata/openai/source.json", @@ -52,8 +52,8 @@ func TestOpenAPIv3ToRESTSchema(t *testing.T) { Schema: "testdata/openai/schema.json", Options: ConvertOptions{}, }, - // go run ./ndc-rest-schema convert -f ./ndc-rest-schema/openapi/testdata/prefix3/source.json -o ./ndc-rest-schema/openapi/testdata/prefix3/expected_single_word.json --spec openapi3 --prefix hasura - // go run ./ndc-rest-schema convert -f ./ndc-rest-schema/openapi/testdata/prefix3/source.json -o ./ndc-rest-schema/openapi/testdata/prefix3/expected_single_word.schema.json --pure --spec openapi3 --prefix hasura + // go run ./ndc-http-schema convert -f ./ndc-http-schema/openapi/testdata/prefix3/source.json -o ./ndc-http-schema/openapi/testdata/prefix3/expected_single_word.json --spec openapi3 --prefix hasura + // go run ./ndc-http-schema convert -f ./ndc-http-schema/openapi/testdata/prefix3/source.json -o ./ndc-http-schema/openapi/testdata/prefix3/expected_single_word.schema.json --pure --spec openapi3 --prefix hasura { Name: "prefix3_single_word", Source: "testdata/prefix3/source.json", @@ -63,8 +63,8 @@ func TestOpenAPIv3ToRESTSchema(t *testing.T) { Prefix: "hasura", }, }, - // go run ./ndc-rest-schema convert -f ./ndc-rest-schema/openapi/testdata/prefix3/source.json -o ./ndc-rest-schema/openapi/testdata/prefix3/expected_multi_words.json --spec openapi3 --prefix hasura_one_signal - // go run ./ndc-rest-schema convert -f ./ndc-rest-schema/openapi/testdata/prefix3/source.json -o ./ndc-rest-schema/openapi/testdata/prefix3/expected_multi_words.schema.json --pure --spec openapi3 --prefix hasura_one_signal + // go run ./ndc-http-schema convert -f ./ndc-http-schema/openapi/testdata/prefix3/source.json -o ./ndc-http-schema/openapi/testdata/prefix3/expected_multi_words.json --spec openapi3 --prefix hasura_one_signal + // go run ./ndc-http-schema convert -f ./ndc-http-schema/openapi/testdata/prefix3/source.json -o ./ndc-http-schema/openapi/testdata/prefix3/expected_multi_words.schema.json --pure --spec openapi3 --prefix hasura_one_signal { Name: "prefix3_multi_words", Source: "testdata/prefix3/source.json", @@ -83,7 +83,7 @@ func TestOpenAPIv3ToRESTSchema(t *testing.T) { expectedBytes, err := os.ReadFile(tc.Expected) assert.NilError(t, err) - var expected schema.NDCRestSchema + var expected schema.NDCHttpSchema assert.NilError(t, json.Unmarshal(expectedBytes, &expected)) output, errs := OpenAPIv3ToNDCSchema(sourceBytes, tc.Options) @@ -102,35 +102,35 @@ func TestOpenAPIv3ToRESTSchema(t *testing.T) { }) } -func assertRESTSchemaEqual(t *testing.T, expected *schema.NDCRestSchema, output *schema.NDCRestSchema) { +func assertRESTSchemaEqual(t *testing.T, expected *schema.NDCHttpSchema, output *schema.NDCHttpSchema) { t.Helper() - assetDeepEqual(t, expected.Settings.Headers, output.Settings.Headers) - assetDeepEqual(t, expected.Settings.Security, output.Settings.Security) - assetDeepEqual(t, expected.Settings.SecuritySchemes, output.Settings.SecuritySchemes) - assetDeepEqual(t, expected.Settings.Version, output.Settings.Version) + assertDeepEqual(t, expected.Settings.Headers, output.Settings.Headers) + assertDeepEqual(t, expected.Settings.Security, output.Settings.Security) + assertDeepEqual(t, expected.Settings.SecuritySchemes, output.Settings.SecuritySchemes) + assertDeepEqual(t, expected.Settings.Version, output.Settings.Version) for i, server := range expected.Settings.Servers { sv := output.Settings.Servers[i] - assetDeepEqual(t, server.Headers, sv.Headers) - assetDeepEqual(t, server.ID, sv.ID) - assetDeepEqual(t, server.Security, sv.Security) - assetDeepEqual(t, server.SecuritySchemes, sv.SecuritySchemes) - assetDeepEqual(t, server.URL, sv.URL) - assetDeepEqual(t, server.TLS, sv.TLS) + assertDeepEqual(t, server.Headers, sv.Headers) + assertDeepEqual(t, server.ID, sv.ID) + assertDeepEqual(t, server.Security, sv.Security) + assertDeepEqual(t, server.SecuritySchemes, sv.SecuritySchemes) + assertDeepEqual(t, server.URL, sv.URL) + assertDeepEqual(t, server.TLS, sv.TLS) } - assetDeepEqual(t, expected.ScalarTypes, output.ScalarTypes) + assertDeepEqual(t, expected.ScalarTypes, output.ScalarTypes) objectBs, _ := json.Marshal(output.ObjectTypes) var objectTypes map[string]schema.ObjectType assert.NilError(t, json.Unmarshal(objectBs, &objectTypes)) - assetDeepEqual(t, expected.ObjectTypes, objectTypes) - assetDeepEqual(t, expected.Procedures, output.Procedures) - assetDeepEqual(t, expected.Functions, output.Functions) + assertDeepEqual(t, expected.ObjectTypes, objectTypes) + assertDeepEqual(t, expected.Procedures, output.Procedures) + assertDeepEqual(t, expected.Functions, output.Functions) } -func assetDeepEqual(t *testing.T, expected any, reality any) { +func assertDeepEqual(t *testing.T, expected any, reality any) { t.Helper() assert.DeepEqual(t, expected, reality, - cmpopts.IgnoreUnexported(schema.ServerConfig{}, schema.NDCRestSettings{}), + cmpopts.IgnoreUnexported(schema.ServerConfig{}, schema.NDCHttpSettings{}), cmp.Exporter(func(t reflect.Type) bool { return true }), ) } diff --git a/ndc-rest-schema/openapi/testdata/jsonplaceholder/expected.json b/ndc-http-schema/openapi/testdata/jsonplaceholder/expected.json similarity index 95% rename from ndc-rest-schema/openapi/testdata/jsonplaceholder/expected.json rename to ndc-http-schema/openapi/testdata/jsonplaceholder/expected.json index 75e0fda..1c9c3c5 100644 --- a/ndc-rest-schema/openapi/testdata/jsonplaceholder/expected.json +++ b/ndc-http-schema/openapi/testdata/jsonplaceholder/expected.json @@ -1,5 +1,5 @@ { - "$schema": "https://raw.githubusercontent.com/hasura/ndc-rest/refs/heads/main/ndc-rest-schema/jsonschema/ndc-rest-schema.schema.json", + "$schema": "https://raw.githubusercontent.com/hasura/ndc-http/refs/heads/main/ndc-http-schema/jsonschema/ndc-http-schema.schema.json", "settings": { "servers": [ { @@ -30,7 +30,7 @@ "type": "named" } }, - "rest": { + "http": { "name": "id", "in": "query", "schema": { @@ -47,7 +47,7 @@ "type": "named" } }, - "rest": { + "http": { "name": "userId", "in": "query", "schema": { @@ -80,7 +80,7 @@ "name": "Int32", "type": "named" }, - "rest": { + "http": { "name": "id", "in": "path", "schema": { @@ -110,7 +110,7 @@ "name": "Int32", "type": "named" }, - "rest": { + "http": { "name": "id", "in": "path", "schema": { @@ -143,7 +143,7 @@ "name": "Int32", "type": "named" }, - "rest": { + "http": { "name": "id", "in": "path", "schema": { @@ -176,7 +176,7 @@ "type": "named" } }, - "rest": { + "http": { "name": "id", "in": "query", "schema": { @@ -193,7 +193,7 @@ "type": "named" } }, - "rest": { + "http": { "name": "postId", "in": "query", "schema": { @@ -226,7 +226,7 @@ "name": "Int32", "type": "named" }, - "rest": { + "http": { "name": "id", "in": "path", "schema": { @@ -259,7 +259,7 @@ "type": "named" } }, - "rest": { + "http": { "name": "albumId", "in": "query", "schema": { @@ -276,7 +276,7 @@ "type": "named" } }, - "rest": { + "http": { "name": "id", "in": "query", "schema": { @@ -309,7 +309,7 @@ "name": "Int32", "type": "named" }, - "rest": { + "http": { "name": "id", "in": "path", "schema": { @@ -342,7 +342,7 @@ "type": "named" } }, - "rest": { + "http": { "name": "id", "in": "query", "schema": { @@ -359,7 +359,7 @@ "type": "named" } }, - "rest": { + "http": { "name": "userId", "in": "query", "schema": { @@ -392,7 +392,7 @@ "name": "Int32", "type": "named" }, - "rest": { + "http": { "name": "id", "in": "path", "schema": { @@ -440,7 +440,7 @@ "name": "Int32", "type": "named" }, - "rest": { + "http": { "name": "id", "in": "path", "schema": { @@ -473,7 +473,7 @@ "type": "named" } }, - "rest": { + "http": { "name": "id", "in": "query", "schema": { @@ -490,7 +490,7 @@ "type": "named" } }, - "rest": { + "http": { "name": "userId", "in": "query", "schema": { @@ -523,7 +523,7 @@ "name": "Int32", "type": "named" }, - "rest": { + "http": { "name": "id", "in": "path", "schema": { @@ -556,7 +556,7 @@ "type": "named" } }, - "rest": { + "http": { "name": "email", "in": "query", "schema": { @@ -573,7 +573,7 @@ "type": "named" } }, - "rest": { + "http": { "name": "id", "in": "query", "schema": { @@ -603,7 +603,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "int64" } @@ -616,7 +616,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -628,7 +628,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "int64" } @@ -645,7 +645,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -657,7 +657,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"], "format": "email" } @@ -670,7 +670,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "int64" } @@ -683,7 +683,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -695,7 +695,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "int64" } @@ -712,7 +712,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "int64" } @@ -725,7 +725,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "int64" } @@ -738,7 +738,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"], "format": "uri" } @@ -751,7 +751,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -763,7 +763,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"], "format": "uri" } @@ -780,7 +780,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -792,7 +792,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "int64" } @@ -805,7 +805,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -817,7 +817,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "int64" } @@ -834,7 +834,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["boolean"] } }, @@ -846,7 +846,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "int64" } @@ -859,7 +859,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -871,7 +871,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "int64" } @@ -888,7 +888,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -900,7 +900,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -912,7 +912,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"], "format": "email" } @@ -925,7 +925,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "int64" } @@ -938,7 +938,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -950,7 +950,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -962,7 +962,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -974,7 +974,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -990,7 +990,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -1002,7 +1002,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -1014,7 +1014,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -1026,7 +1026,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -1038,7 +1038,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -1054,7 +1054,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -1066,7 +1066,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -1082,7 +1082,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -1094,7 +1094,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -1106,7 +1106,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -1132,7 +1132,7 @@ "name": "Post", "type": "named" }, - "rest": { + "http": { "in": "body", "schema": { "type": ["object"] @@ -1161,7 +1161,7 @@ "name": "Int32", "type": "named" }, - "rest": { + "http": { "name": "id", "in": "path", "schema": { @@ -1197,7 +1197,7 @@ "name": "Post", "type": "named" }, - "rest": { + "http": { "in": "body", "schema": { "type": ["object"] @@ -1210,7 +1210,7 @@ "name": "Int32", "type": "named" }, - "rest": { + "http": { "name": "id", "in": "path", "schema": { @@ -1243,7 +1243,7 @@ "name": "Post", "type": "named" }, - "rest": { + "http": { "in": "body", "schema": { "type": ["object"] @@ -1256,7 +1256,7 @@ "name": "Int32", "type": "named" }, - "rest": { + "http": { "name": "id", "in": "path", "schema": { diff --git a/ndc-rest-schema/openapi/testdata/jsonplaceholder/schema.json b/ndc-http-schema/openapi/testdata/jsonplaceholder/schema.json similarity index 100% rename from ndc-rest-schema/openapi/testdata/jsonplaceholder/schema.json rename to ndc-http-schema/openapi/testdata/jsonplaceholder/schema.json diff --git a/ndc-rest-schema/openapi/testdata/jsonplaceholder/swagger.json b/ndc-http-schema/openapi/testdata/jsonplaceholder/swagger.json similarity index 99% rename from ndc-rest-schema/openapi/testdata/jsonplaceholder/swagger.json rename to ndc-http-schema/openapi/testdata/jsonplaceholder/swagger.json index fd825b3..e090c89 100644 --- a/ndc-rest-schema/openapi/testdata/jsonplaceholder/swagger.json +++ b/ndc-http-schema/openapi/testdata/jsonplaceholder/swagger.json @@ -1,7 +1,7 @@ { "swagger": "2.0", "info": { - "description": "Fake Online REST API for Testing and Prototyping", + "description": "Fake Online HTTP API for Testing and Prototyping", "version": "1.0.0", "title": "JSON Placeholder" }, diff --git a/ndc-rest-schema/openapi/testdata/onesignal/config.yaml b/ndc-http-schema/openapi/testdata/onesignal/config.yaml similarity index 100% rename from ndc-rest-schema/openapi/testdata/onesignal/config.yaml rename to ndc-http-schema/openapi/testdata/onesignal/config.yaml diff --git a/ndc-rest-schema/openapi/testdata/onesignal/expected-patch.json b/ndc-http-schema/openapi/testdata/onesignal/expected-patch.json similarity index 96% rename from ndc-rest-schema/openapi/testdata/onesignal/expected-patch.json rename to ndc-http-schema/openapi/testdata/onesignal/expected-patch.json index dff9e87..2b3b8f9 100644 --- a/ndc-rest-schema/openapi/testdata/onesignal/expected-patch.json +++ b/ndc-http-schema/openapi/testdata/onesignal/expected-patch.json @@ -1,5 +1,5 @@ { - "$schema": "https://raw.githubusercontent.com/hasura/ndc-rest/refs/heads/main/ndc-rest-schema/jsonschema/ndc-rest-schema.schema.json", + "$schema": "https://raw.githubusercontent.com/hasura/ndc-http/refs/heads/main/ndc-http-schema/jsonschema/ndc-http-schema.schema.json", "settings": { "servers": [ { @@ -58,7 +58,7 @@ "name": "NotificationInput", "type": "named" }, - "rest": { + "http": { "in": "body" } } @@ -105,7 +105,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "name": "app_id", "in": "query", "schema": { @@ -118,7 +118,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "name": "notification_id", "in": "path", "schema": { diff --git a/ndc-rest-schema/openapi/testdata/onesignal/expected.json b/ndc-http-schema/openapi/testdata/onesignal/expected.json similarity index 94% rename from ndc-rest-schema/openapi/testdata/onesignal/expected.json rename to ndc-http-schema/openapi/testdata/onesignal/expected.json index 4690d6e..919a2eb 100644 --- a/ndc-rest-schema/openapi/testdata/onesignal/expected.json +++ b/ndc-http-schema/openapi/testdata/onesignal/expected.json @@ -1,5 +1,5 @@ { - "$schema": "https://raw.githubusercontent.com/hasura/ndc-rest/refs/heads/main/ndc-rest-schema/jsonschema/ndc-rest-schema.schema.json", + "$schema": "https://raw.githubusercontent.com/hasura/ndc-http/refs/heads/main/ndc-http-schema/jsonschema/ndc-http-schema.schema.json", "settings": { "servers": [ { @@ -49,7 +49,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "name": "app_id", "in": "query", "schema": { @@ -62,7 +62,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "name": "notification_id", "in": "path", "schema": { @@ -98,7 +98,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "name": "app_id", "in": "query", "schema": { @@ -115,7 +115,7 @@ "type": "named" } }, - "rest": { + "http": { "name": "kind", "in": "query", "schema": { @@ -132,7 +132,7 @@ "type": "named" } }, - "rest": { + "http": { "name": "limit", "in": "query", "schema": { @@ -149,7 +149,7 @@ "type": "named" } }, - "rest": { + "http": { "name": "offset", "in": "query", "schema": { @@ -177,7 +177,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["boolean"] } } @@ -193,7 +193,7 @@ "type": "named" } }, - "rest": { + "http": { "type": null } }, @@ -205,7 +205,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -217,7 +217,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -229,7 +229,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } } @@ -246,7 +246,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } }, @@ -259,7 +259,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } }, @@ -272,7 +272,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } }, @@ -285,7 +285,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } }, @@ -298,7 +298,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } } @@ -312,7 +312,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "type": ["string"] } }, @@ -325,7 +325,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -335,7 +335,7 @@ "name": "FilterRelation", "type": "named" }, - "rest": { + "http": { "type": ["string"] } }, @@ -348,7 +348,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -364,7 +364,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -377,7 +377,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -390,7 +390,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -406,7 +406,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -418,7 +418,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["boolean"] } } @@ -434,7 +434,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -446,7 +446,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -459,7 +459,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -474,7 +474,7 @@ "type": "array" } }, - "rest": { + "http": { "type": ["array"] } }, @@ -486,7 +486,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -498,7 +498,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -510,7 +510,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"], "format": "date-time" } @@ -523,7 +523,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } } @@ -539,7 +539,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } }, @@ -554,7 +554,7 @@ "type": "array" } }, - "rest": { + "http": { "type": ["array"] } }, @@ -566,7 +566,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } }, @@ -578,7 +578,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } } @@ -595,7 +595,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "int64" } @@ -608,7 +608,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -621,7 +621,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } }, @@ -634,7 +634,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } }, @@ -649,7 +649,7 @@ "type": "array" } }, - "rest": { + "http": { "type": ["array"], "items": { "type": ["string"] @@ -665,7 +665,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } }, @@ -680,7 +680,7 @@ "type": "array" } }, - "rest": { + "http": { "type": ["array"] } }, @@ -692,7 +692,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -704,7 +704,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -719,7 +719,7 @@ "type": "array" } }, - "rest": { + "http": { "type": ["array"], "items": { "type": ["string"] @@ -737,7 +737,7 @@ "type": "array" } }, - "rest": { + "http": { "type": ["array"], "items": { "type": ["string"] @@ -755,7 +755,7 @@ "type": "array" } }, - "rest": { + "http": { "type": ["array"] } }, @@ -768,7 +768,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -781,7 +781,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "int64" } @@ -795,7 +795,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } }, @@ -808,7 +808,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } }, @@ -821,7 +821,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "int64" } @@ -834,7 +834,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -847,7 +847,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } }, @@ -859,7 +859,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -872,7 +872,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } } @@ -885,7 +885,7 @@ "name": "OutcomeDataAggregation", "type": "named" }, - "rest": { + "http": { "type": ["string"] } }, @@ -894,7 +894,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "type": ["string"] } }, @@ -903,7 +903,7 @@ "name": "Int32", "type": "named" }, - "rest": { + "http": { "type": ["integer"] } } @@ -920,7 +920,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -932,7 +932,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -944,7 +944,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -956,7 +956,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -968,7 +968,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -980,7 +980,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -992,7 +992,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -1004,7 +1004,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } } @@ -1021,7 +1021,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -1048,7 +1048,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "name": "app_id", "in": "query", "schema": { @@ -1061,7 +1061,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "name": "notification_id", "in": "path", "schema": { @@ -1100,7 +1100,7 @@ "name": "NotificationInput", "type": "named" }, - "rest": { + "http": { "in": "body" } } @@ -1135,7 +1135,7 @@ "name": "GetNotificationHistoryBody", "type": "named" }, - "rest": { + "http": { "in": "body" } }, @@ -1145,7 +1145,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "name": "notification_id", "in": "path", "schema": { diff --git a/ndc-rest-schema/openapi/testdata/onesignal/patch-after.json b/ndc-http-schema/openapi/testdata/onesignal/patch-after.json similarity index 100% rename from ndc-rest-schema/openapi/testdata/onesignal/patch-after.json rename to ndc-http-schema/openapi/testdata/onesignal/patch-after.json diff --git a/ndc-rest-schema/openapi/testdata/onesignal/patch-before.json b/ndc-http-schema/openapi/testdata/onesignal/patch-before.json similarity index 100% rename from ndc-rest-schema/openapi/testdata/onesignal/patch-before.json rename to ndc-http-schema/openapi/testdata/onesignal/patch-before.json diff --git a/ndc-rest-schema/openapi/testdata/onesignal/schema.json b/ndc-http-schema/openapi/testdata/onesignal/schema.json similarity index 100% rename from ndc-rest-schema/openapi/testdata/onesignal/schema.json rename to ndc-http-schema/openapi/testdata/onesignal/schema.json diff --git a/ndc-rest-schema/openapi/testdata/onesignal/source.json b/ndc-http-schema/openapi/testdata/onesignal/source.json similarity index 99% rename from ndc-rest-schema/openapi/testdata/onesignal/source.json rename to ndc-http-schema/openapi/testdata/onesignal/source.json index 0c20a6b..aea9149 100644 --- a/ndc-rest-schema/openapi/testdata/onesignal/source.json +++ b/ndc-http-schema/openapi/testdata/onesignal/source.json @@ -868,7 +868,7 @@ "post": { "operationId": "get_notification_history", "summary": "Notification History", - "description": "-> View the devices sent a message - OneSignal Paid Plan Required This method will return all devices that were sent the given notification_id of an Email or Push Notification if used within 7 days of the date sent. After 7 days of the sending date, the message history data will be unavailable. After a successful response is received, the destination url may be polled until the file becomes available. Most exports are done in ~1-3 minutes, so setting a poll interval of 10 seconds should be adequate. For use cases that are not meant to be consumed by a script, an email will be sent to the supplied email address. 🚧 Requirements A OneSignal Paid Plan. Turn on Send History via OneSignal API in Settings -> Analytics. Cannot get data before this was turned on. Must be called within 7 days after sending the message. Messages targeting under 1000 recipients will not have \"sent\" events recorded, but will show \"clicked\" events. Requires your OneSignal App's REST API Key, available in Keys & IDs.", + "description": "-> View the devices sent a message - OneSignal Paid Plan Required This method will return all devices that were sent the given notification_id of an Email or Push Notification if used within 7 days of the date sent. After 7 days of the sending date, the message history data will be unavailable. After a successful response is received, the destination url may be polled until the file becomes available. Most exports are done in ~1-3 minutes, so setting a poll interval of 10 seconds should be adequate. For use cases that are not meant to be consumed by a script, an email will be sent to the supplied email address. 🚧 Requirements A OneSignal Paid Plan. Turn on Send History via OneSignal API in Settings -> Analytics. Cannot get data before this was turned on. Must be called within 7 days after sending the message. Messages targeting under 1000 recipients will not have \"sent\" events recorded, but will show \"clicked\" events. Requires your OneSignal App's HTTP API Key, available in Keys & IDs.", "parameters": [ { "name": "notification_id", diff --git a/ndc-rest-schema/openapi/testdata/openai/expected.json b/ndc-http-schema/openapi/testdata/openai/expected.json similarity index 96% rename from ndc-rest-schema/openapi/testdata/openai/expected.json rename to ndc-http-schema/openapi/testdata/openai/expected.json index 4cc2f5c..894716b 100644 --- a/ndc-rest-schema/openapi/testdata/openai/expected.json +++ b/ndc-http-schema/openapi/testdata/openai/expected.json @@ -1,5 +1,5 @@ { - "$schema": "https://raw.githubusercontent.com/hasura/ndc-rest/refs/heads/main/ndc-rest-schema/jsonschema/ndc-rest-schema.schema.json", + "$schema": "https://raw.githubusercontent.com/hasura/ndc-http/refs/heads/main/ndc-http-schema/jsonschema/ndc-http-schema.schema.json", "settings": { "servers": [ { @@ -45,7 +45,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -55,7 +55,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "type": ["string"] } }, @@ -68,7 +68,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } } @@ -82,7 +82,7 @@ "name": "ChatCompletionMessageToolCallFunction", "type": "named" }, - "rest": { + "http": { "type": ["object"] } }, @@ -92,7 +92,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "type": ["string"] } }, @@ -102,7 +102,7 @@ "name": "ChatCompletionMessageToolCallType", "type": "named" }, - "rest": { + "http": { "type": ["string"] } } @@ -117,7 +117,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "type": ["string"] } }, @@ -127,7 +127,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "type": ["string"] } } @@ -142,7 +142,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "type": ["string"] } }, @@ -155,7 +155,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -165,7 +165,7 @@ "name": "ChatCompletionResponseMessageRole", "type": "named" }, - "rest": { + "http": { "type": ["string"] } }, @@ -181,7 +181,7 @@ "type": "array" } }, - "rest": { + "http": { "type": ["array"] } } @@ -196,7 +196,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "type": ["string"] } }, @@ -206,7 +206,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "type": ["string"] } } @@ -224,7 +224,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["boolean"] } } @@ -241,7 +241,7 @@ }, "type": "array" }, - "rest": { + "http": { "type": ["array"], "items": { "type": ["integer"] @@ -254,7 +254,7 @@ "name": "Float64", "type": "named" }, - "rest": { + "http": { "type": ["number"] } }, @@ -264,7 +264,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "type": ["string"] } }, @@ -277,7 +277,7 @@ }, "type": "array" }, - "rest": { + "http": { "type": ["array"], "items": { "type": ["object"] @@ -297,7 +297,7 @@ }, "type": "array" }, - "rest": { + "http": { "type": ["array"], "items": { "type": ["integer"] @@ -310,7 +310,7 @@ "name": "Float64", "type": "named" }, - "rest": { + "http": { "type": ["number"] } }, @@ -320,7 +320,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "type": ["string"] } } @@ -333,7 +333,7 @@ "name": "FunctionObject", "type": "named" }, - "rest": { + "http": { "type": ["object"] } }, @@ -343,7 +343,7 @@ "name": "ChatCompletionToolType", "type": "named" }, - "rest": { + "http": { "type": ["string"] } } @@ -360,7 +360,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["number"], "maximum": 2, "minimum": -2 @@ -375,7 +375,7 @@ "type": "named" } }, - "rest": { + "http": { "type": null } }, @@ -391,7 +391,7 @@ "type": "array" } }, - "rest": { + "http": { "type": ["array"] } }, @@ -404,7 +404,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -417,7 +417,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["boolean"] } }, @@ -430,7 +430,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } }, @@ -443,7 +443,7 @@ }, "type": "array" }, - "rest": { + "http": { "type": ["array"] } }, @@ -453,7 +453,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "type": ["string"] } }, @@ -466,7 +466,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "maximum": 128, "minimum": 1 @@ -481,7 +481,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["boolean"] } }, @@ -494,7 +494,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["number"], "maximum": 2, "minimum": -2 @@ -509,7 +509,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -522,7 +522,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "maximum": 9223372036854776000, "minimum": -9223372036854776000 @@ -537,7 +537,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -550,7 +550,7 @@ "type": "named" } }, - "rest": { + "http": { "type": null } }, @@ -563,7 +563,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["boolean"] } }, @@ -576,7 +576,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -589,7 +589,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["number"], "maximum": 2, "minimum": 0 @@ -604,7 +604,7 @@ "type": "named" } }, - "rest": { + "http": { "type": null } }, @@ -620,7 +620,7 @@ "type": "array" } }, - "rest": { + "http": { "type": ["array"] } }, @@ -633,7 +633,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "maximum": 20, "minimum": 0 @@ -648,7 +648,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["number"], "maximum": 1, "minimum": 0 @@ -663,7 +663,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -681,7 +681,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -699,7 +699,7 @@ }, "type": "array" }, - "rest": { + "http": { "type": ["array"], "items": { "type": ["object"] @@ -712,7 +712,7 @@ "name": "Int32", "type": "named" }, - "rest": { + "http": { "type": ["integer"] } }, @@ -722,7 +722,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "type": ["string"] } }, @@ -732,7 +732,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "type": ["string"] } }, @@ -742,7 +742,7 @@ "name": "CreateChatCompletionResponseObject", "type": "named" }, - "rest": { + "http": { "type": ["string"] } }, @@ -755,7 +755,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -768,7 +768,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -782,7 +782,7 @@ "name": "CreateChatCompletionResponseChoicesFinishReason", "type": "named" }, - "rest": { + "http": { "type": ["string"] } }, @@ -792,7 +792,7 @@ "name": "Int32", "type": "named" }, - "rest": { + "http": { "type": ["integer"] } }, @@ -802,7 +802,7 @@ "name": "CreateChatCompletionResponseChoicesLogprobs", "type": "named" }, - "rest": { + "http": { "type": ["object"] } }, @@ -812,7 +812,7 @@ "name": "ChatCompletionResponseMessage", "type": "named" }, - "rest": { + "http": { "type": ["object"] } } @@ -830,7 +830,7 @@ }, "type": "array" }, - "rest": { + "http": { "type": ["array"] } } @@ -847,7 +847,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -864,7 +864,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -874,7 +874,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "type": ["string"] } }, @@ -887,7 +887,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } } @@ -904,7 +904,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } }, @@ -917,7 +917,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -930,7 +930,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -943,7 +943,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } } @@ -969,7 +969,7 @@ "name": "CreateChatCompletionRequest", "type": "named" }, - "rest": { + "http": { "in": "body" } } @@ -999,7 +999,7 @@ "name": "CreateModelRequest", "type": "named" }, - "rest": { + "http": { "in": "body" } } diff --git a/ndc-rest-schema/openapi/testdata/openai/schema.json b/ndc-http-schema/openapi/testdata/openai/schema.json similarity index 100% rename from ndc-rest-schema/openapi/testdata/openai/schema.json rename to ndc-http-schema/openapi/testdata/openai/schema.json diff --git a/ndc-rest-schema/openapi/testdata/openai/source.json b/ndc-http-schema/openapi/testdata/openai/source.json similarity index 99% rename from ndc-rest-schema/openapi/testdata/openai/source.json rename to ndc-http-schema/openapi/testdata/openai/source.json index e448f1f..03a4091 100644 --- a/ndc-rest-schema/openapi/testdata/openai/source.json +++ b/ndc-http-schema/openapi/testdata/openai/source.json @@ -2,7 +2,7 @@ "openapi": "3.0.0", "info": { "title": "OpenAI API", - "description": "The OpenAI REST API. Please see https://platform.openai.com/docs/api-reference for more details.", + "description": "The OpenAI HTTP API. Please see https://platform.openai.com/docs/api-reference for more details.", "version": "2.1.0", "termsOfService": "https://openai.com/policies/terms-of-use", "contact": { diff --git a/ndc-rest-schema/openapi/testdata/petstore2/expected.json b/ndc-http-schema/openapi/testdata/petstore2/expected.json similarity index 95% rename from ndc-rest-schema/openapi/testdata/petstore2/expected.json rename to ndc-http-schema/openapi/testdata/petstore2/expected.json index 3fdff0b..bbd96a0 100644 --- a/ndc-rest-schema/openapi/testdata/petstore2/expected.json +++ b/ndc-http-schema/openapi/testdata/petstore2/expected.json @@ -1,5 +1,5 @@ { - "$schema": "https://raw.githubusercontent.com/hasura/ndc-rest/refs/heads/main/ndc-rest-schema/jsonschema/ndc-rest-schema.schema.json", + "$schema": "https://raw.githubusercontent.com/hasura/ndc-http/refs/heads/main/ndc-http-schema/jsonschema/ndc-http-schema.schema.json", "settings": { "servers": [ { @@ -65,7 +65,7 @@ }, "type": "array" }, - "rest": { + "http": { "name": "status", "in": "query", "schema": { @@ -107,7 +107,7 @@ }, "type": "array" }, - "rest": { + "http": { "name": "tags", "in": "query", "schema": { @@ -162,7 +162,7 @@ "name": "Int64", "type": "named" }, - "rest": { + "http": { "name": "orderId", "in": "path", "schema": { @@ -200,7 +200,7 @@ "name": "Int64", "type": "named" }, - "rest": { + "http": { "name": "petId", "in": "path", "schema": { @@ -247,7 +247,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "name": "username", "in": "path", "schema": { @@ -281,7 +281,7 @@ "type": "named" } }, - "rest": { + "http": { "name": "client_name", "in": "query", "schema": { @@ -298,7 +298,7 @@ "type": "named" } }, - "rest": { + "http": { "name": "limit", "in": "query", "schema": { @@ -315,7 +315,7 @@ "type": "named" } }, - "rest": { + "http": { "name": "offset", "in": "query", "schema": { @@ -332,7 +332,7 @@ "type": "named" } }, - "rest": { + "http": { "name": "owner", "in": "query", "schema": { @@ -366,7 +366,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "name": "password", "in": "query", "schema": { @@ -380,7 +380,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "name": "username", "in": "query", "schema": { @@ -408,7 +408,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "int32" } @@ -421,7 +421,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -433,7 +433,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -449,7 +449,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "int64" } @@ -462,7 +462,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -479,7 +479,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -492,7 +492,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -505,7 +505,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -518,7 +518,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "int64" } @@ -532,7 +532,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -548,7 +548,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["boolean"] } }, @@ -560,7 +560,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "int64" } @@ -573,7 +573,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "int64" } @@ -586,7 +586,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "int32" } @@ -599,7 +599,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"], "format": "date-time" } @@ -613,7 +613,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -629,7 +629,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -641,7 +641,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "int64" } @@ -651,7 +651,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "type": ["string"] } }, @@ -663,7 +663,7 @@ }, "type": "array" }, - "rest": { + "http": { "type": ["array"], "items": { "type": ["string"] @@ -679,7 +679,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -694,7 +694,7 @@ "type": "array" } }, - "rest": { + "http": { "type": ["array"] } } @@ -710,7 +710,7 @@ "type": "named" } }, - "rest": { + "http": { "type": null } }, @@ -722,7 +722,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "int64" } @@ -735,7 +735,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -751,7 +751,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "int64" } @@ -764,7 +764,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -781,7 +781,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -794,7 +794,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -811,7 +811,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -824,7 +824,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["file"] } } @@ -840,7 +840,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -852,7 +852,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -864,7 +864,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "int64" } @@ -877,7 +877,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -889,7 +889,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -901,7 +901,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -914,7 +914,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "int32" } @@ -927,7 +927,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -958,7 +958,7 @@ "name": "Pet", "type": "named" }, - "rest": { + "http": { "in": "body", "schema": { "type": ["object"] @@ -1007,7 +1007,7 @@ "name": "Int64", "type": "named" }, - "rest": { + "http": { "name": "orderId", "in": "path", "schema": { @@ -1049,7 +1049,7 @@ "type": "named" } }, - "rest": { + "http": { "name": "api_key", "in": "header", "schema": { @@ -1063,7 +1063,7 @@ "name": "Int64", "type": "named" }, - "rest": { + "http": { "name": "petId", "in": "path", "schema": { @@ -1097,7 +1097,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "name": "username", "in": "path", "schema": { @@ -1133,7 +1133,7 @@ "name": "OAuth2Client", "type": "named" }, - "rest": { + "http": { "in": "body", "schema": { "type": ["object"] @@ -1166,7 +1166,7 @@ "name": "Order", "type": "named" }, - "rest": { + "http": { "in": "body", "schema": { "type": ["object"] @@ -1204,7 +1204,7 @@ "name": "Pet", "type": "named" }, - "rest": { + "http": { "in": "body", "schema": { "type": ["object"] @@ -1245,7 +1245,7 @@ "name": "UpdatePetWithFormBody", "type": "named" }, - "rest": { + "http": { "in": "formData", "schema": { "type": ["object"] @@ -1258,7 +1258,7 @@ "name": "Int64", "type": "named" }, - "rest": { + "http": { "name": "petId", "in": "path", "schema": { @@ -1295,7 +1295,7 @@ "name": "User", "type": "named" }, - "rest": { + "http": { "in": "body", "schema": { "type": ["object"] @@ -1308,7 +1308,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "name": "username", "in": "path", "schema": { @@ -1350,7 +1350,7 @@ "name": "UploadFileBody", "type": "named" }, - "rest": { + "http": { "in": "formData", "schema": { "type": ["object"] @@ -1363,7 +1363,7 @@ "name": "Int64", "type": "named" }, - "rest": { + "http": { "name": "petId", "in": "path", "schema": { diff --git a/ndc-rest-schema/openapi/testdata/petstore2/schema.json b/ndc-http-schema/openapi/testdata/petstore2/schema.json similarity index 100% rename from ndc-rest-schema/openapi/testdata/petstore2/schema.json rename to ndc-http-schema/openapi/testdata/petstore2/schema.json diff --git a/ndc-rest-schema/openapi/testdata/petstore2/swagger.json b/ndc-http-schema/openapi/testdata/petstore2/swagger.json similarity index 100% rename from ndc-rest-schema/openapi/testdata/petstore2/swagger.json rename to ndc-http-schema/openapi/testdata/petstore2/swagger.json diff --git a/ndc-rest-schema/openapi/testdata/petstore3/expected.json b/ndc-http-schema/openapi/testdata/petstore3/expected.json similarity index 95% rename from ndc-rest-schema/openapi/testdata/petstore3/expected.json rename to ndc-http-schema/openapi/testdata/petstore3/expected.json index 9d7de44..a65275c 100644 --- a/ndc-rest-schema/openapi/testdata/petstore3/expected.json +++ b/ndc-http-schema/openapi/testdata/petstore3/expected.json @@ -1,5 +1,5 @@ { - "$schema": "https://raw.githubusercontent.com/hasura/ndc-rest/refs/heads/main/ndc-rest-schema/jsonschema/ndc-rest-schema.schema.json", + "$schema": "https://raw.githubusercontent.com/hasura/ndc-http/refs/heads/main/ndc-http-schema/jsonschema/ndc-http-schema.schema.json", "settings": { "servers": [ { @@ -72,7 +72,7 @@ "type": "named" } }, - "rest": { + "http": { "style": "form", "name": "collection_method", "in": "query", @@ -90,7 +90,7 @@ "type": "named" } }, - "rest": { + "http": { "style": "deepObject", "explode": true, "name": "created", @@ -109,7 +109,7 @@ "type": "named" } }, - "rest": { + "http": { "style": "form", "name": "customer", "in": "query", @@ -127,7 +127,7 @@ "type": "named" } }, - "rest": { + "http": { "style": "deepObject", "explode": true, "name": "due_date", @@ -146,7 +146,7 @@ "type": "named" } }, - "rest": { + "http": { "style": "form", "name": "ending_before", "in": "query", @@ -168,7 +168,7 @@ "type": "array" } }, - "rest": { + "http": { "style": "deepObject", "explode": true, "name": "expand", @@ -191,7 +191,7 @@ "type": "named" } }, - "rest": { + "http": { "style": "form", "name": "limit", "in": "query", @@ -209,7 +209,7 @@ "type": "named" } }, - "rest": { + "http": { "style": "form", "name": "starting_after", "in": "query", @@ -228,7 +228,7 @@ "type": "named" } }, - "rest": { + "http": { "style": "form", "name": "status", "in": "query", @@ -246,7 +246,7 @@ "type": "named" } }, - "rest": { + "http": { "style": "form", "name": "subscription", "in": "query", @@ -286,7 +286,7 @@ "type": "named" } }, - "rest": { + "http": { "explode": true, "name": "status", "in": "query", @@ -331,7 +331,7 @@ "type": "array" } }, - "rest": { + "http": { "explode": true, "name": "tags", "in": "query", @@ -388,7 +388,7 @@ "name": "Int64", "type": "named" }, - "rest": { + "http": { "name": "orderId", "in": "path", "schema": { @@ -427,7 +427,7 @@ "name": "Int64", "type": "named" }, - "rest": { + "http": { "name": "petId", "in": "path", "schema": { @@ -473,7 +473,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "name": "username", "in": "path", "schema": { @@ -506,7 +506,7 @@ "type": "named" } }, - "rest": { + "http": { "name": "password", "in": "query", "schema": { @@ -523,7 +523,7 @@ "type": "named" } }, - "rest": { + "http": { "name": "username", "in": "query", "schema": { @@ -550,7 +550,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -562,7 +562,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -574,7 +574,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -586,7 +586,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -602,7 +602,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "int32" } @@ -615,7 +615,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -627,7 +627,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -643,7 +643,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "int64" } @@ -656,7 +656,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -672,7 +672,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -686,7 +686,7 @@ "name": "Boolean", "type": "named" }, - "rest": { + "http": { "type": ["boolean"] } }, @@ -696,7 +696,7 @@ "name": "InvoicesObject", "type": "named" }, - "rest": { + "http": { "type": ["string"] } }, @@ -706,7 +706,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "type": ["string"], "pattern": "^/v1/invoices", "maxLength": 5000 @@ -724,7 +724,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["boolean"] } }, @@ -736,7 +736,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "int64" } @@ -749,7 +749,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "int64" } @@ -762,7 +762,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "int32" } @@ -775,7 +775,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"], "format": "date-time" } @@ -789,7 +789,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -805,7 +805,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -817,7 +817,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "int64" } @@ -827,7 +827,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "type": ["string"] } }, @@ -839,7 +839,7 @@ }, "type": "array" }, - "rest": { + "http": { "type": ["array"], "items": { "type": ["string"] @@ -855,7 +855,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -870,7 +870,7 @@ "type": "array" } }, - "rest": { + "http": { "type": ["array"] } } @@ -887,7 +887,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -900,7 +900,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["boolean"] } }, @@ -913,7 +913,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -926,7 +926,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -939,7 +939,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"], "maxLength": 5000 } @@ -953,7 +953,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"], "maxLength": 200 } @@ -967,7 +967,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -980,7 +980,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -996,7 +996,7 @@ "type": "array" } }, - "rest": { + "http": { "type": ["array"], "items": { "type": ["object"] @@ -1012,7 +1012,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -1025,7 +1025,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"], "maxLength": 5000 } @@ -1039,7 +1039,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -1052,7 +1052,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -1065,7 +1065,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -1081,7 +1081,7 @@ "type": "array" } }, - "rest": { + "http": { "type": ["array"], "items": { "type": ["object"] @@ -1100,7 +1100,7 @@ "type": "array" } }, - "rest": { + "http": { "type": ["array"], "items": { "type": ["string"], @@ -1117,7 +1117,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "unix-time" } @@ -1131,7 +1131,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -1147,7 +1147,7 @@ "type": "array" } }, - "rest": { + "http": { "type": ["array"], "items": { "type": ["object"] @@ -1163,7 +1163,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -1176,7 +1176,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -1189,7 +1189,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -1202,7 +1202,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -1215,7 +1215,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -1228,7 +1228,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"], "maxLength": 100 } @@ -1242,7 +1242,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -1258,7 +1258,7 @@ "type": "array" } }, - "rest": { + "http": { "type": ["array"], "items": { "type": ["string"] @@ -1274,7 +1274,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -1287,7 +1287,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -1300,7 +1300,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"], "maxLength": 5000 } @@ -1314,7 +1314,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -1327,7 +1327,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -1343,7 +1343,7 @@ "type": "array" } }, - "rest": { + "http": { "type": ["array"], "items": { "type": ["object"] @@ -1359,7 +1359,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -1372,7 +1372,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -1385,7 +1385,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"], "maxLength": 5000 } @@ -1399,7 +1399,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -1412,7 +1412,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -1429,7 +1429,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } } @@ -1445,7 +1445,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["boolean"] } }, @@ -1454,7 +1454,7 @@ "name": "Boolean", "type": "named" }, - "rest": { + "http": { "type": ["boolean"] } } @@ -1468,7 +1468,7 @@ "name": "Boolean", "type": "named" }, - "rest": { + "http": { "type": ["boolean"] } }, @@ -1480,7 +1480,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } } @@ -1496,7 +1496,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -1505,7 +1505,7 @@ "name": "CheckoutType", "type": "named" }, - "rest": { + "http": { "type": ["string"] } } @@ -1522,7 +1522,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -1534,7 +1534,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -1546,7 +1546,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -1559,7 +1559,7 @@ "name": "CheckoutPosition", "type": "named" }, - "rest": { + "http": { "type": ["string"] } } @@ -1575,7 +1575,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -1584,7 +1584,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "type": ["string"], "maxLength": 200 } @@ -1594,7 +1594,7 @@ "name": "PostCheckoutSessionsBodyCustomFieldsLabel", "type": "named" }, - "rest": { + "http": { "type": ["object"] } }, @@ -1606,7 +1606,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -1618,7 +1618,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["boolean"] } }, @@ -1630,7 +1630,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -1639,7 +1639,7 @@ "name": "PostCheckoutSessionsBodyCustomFieldsType", "type": "named" }, - "rest": { + "http": { "type": ["string"] } } @@ -1655,7 +1655,7 @@ }, "type": "array" }, - "rest": { + "http": { "type": ["array"], "items": { "type": ["object"] @@ -1671,7 +1671,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "type": ["string"], "maxLength": 100 } @@ -1681,7 +1681,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "type": ["string"], "maxLength": 100 } @@ -1695,7 +1695,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "type": ["string"], "maxLength": 50 } @@ -1705,7 +1705,7 @@ "name": "PostCheckoutSessionsBodyCustomFieldsLabelType", "type": "named" }, - "rest": { + "http": { "type": ["string"] } } @@ -1721,7 +1721,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } }, @@ -1733,7 +1733,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } } @@ -1749,7 +1749,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } }, @@ -1761,7 +1761,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } } @@ -1778,7 +1778,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -1790,7 +1790,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -1802,7 +1802,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -1814,7 +1814,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } } @@ -1827,7 +1827,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "type": ["string"], "maxLength": 1200 } @@ -1841,7 +1841,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "type": ["string"], "maxLength": 1200 } @@ -1855,7 +1855,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "type": ["string"], "maxLength": 1200 } @@ -1869,7 +1869,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "type": ["string"], "maxLength": 1200 } @@ -1887,7 +1887,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -1899,7 +1899,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -1911,7 +1911,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -1927,7 +1927,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"], "maxLength": 5000 } @@ -1940,7 +1940,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"], "maxLength": 5000 } @@ -1955,7 +1955,7 @@ "name": "Boolean", "type": "named" }, - "rest": { + "http": { "type": ["boolean"] } }, @@ -1967,7 +1967,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } } @@ -1986,7 +1986,7 @@ "type": "array" } }, - "rest": { + "http": { "type": ["array"], "items": { "type": ["string"], @@ -2005,7 +2005,7 @@ "type": "array" } }, - "rest": { + "http": { "type": ["array"], "items": { "type": ["object"] @@ -2020,7 +2020,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"], "maxLength": 1500 } @@ -2033,7 +2033,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"], "maxLength": 5000 } @@ -2046,7 +2046,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -2058,7 +2058,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -2070,7 +2070,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } } @@ -2083,7 +2083,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "type": ["string"], "maxLength": 40 } @@ -2093,7 +2093,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "type": ["string"], "maxLength": 140 } @@ -2110,7 +2110,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -2119,7 +2119,7 @@ "name": "CheckoutType", "type": "named" }, - "rest": { + "http": { "type": ["string"] } } @@ -2135,7 +2135,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -2151,7 +2151,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -2166,7 +2166,7 @@ "type": "array" } }, - "rest": { + "http": { "type": ["array"], "items": { "type": ["string"], @@ -2182,7 +2182,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"], "maxLength": 5000 } @@ -2195,7 +2195,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -2207,7 +2207,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } }, @@ -2222,7 +2222,7 @@ "type": "array" } }, - "rest": { + "http": { "type": ["array"], "items": { "type": ["string"], @@ -2239,7 +2239,7 @@ "name": "Boolean", "type": "named" }, - "rest": { + "http": { "type": ["boolean"] } }, @@ -2251,7 +2251,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } }, @@ -2263,7 +2263,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } } @@ -2276,7 +2276,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "type": ["string"] } }, @@ -2288,7 +2288,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"], "maxLength": 5000 } @@ -2301,7 +2301,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -2313,7 +2313,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -2325,7 +2325,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -2337,7 +2337,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } }, @@ -2349,7 +2349,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"], "format": "decimal" } @@ -2366,7 +2366,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"], "maxLength": 40000 } @@ -2382,7 +2382,7 @@ "type": "array" } }, - "rest": { + "http": { "type": ["array"], "items": { "type": ["string"] @@ -2397,7 +2397,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -2406,7 +2406,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "type": ["string"], "maxLength": 5000 } @@ -2419,7 +2419,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"], "maxLength": 5000 } @@ -2433,7 +2433,7 @@ "name": "CheckoutInterval", "type": "named" }, - "rest": { + "http": { "type": ["string"] } }, @@ -2445,7 +2445,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } } @@ -2462,7 +2462,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } }, @@ -2474,7 +2474,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -2486,7 +2486,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"], "maxLength": 1000 } @@ -2499,7 +2499,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -2511,7 +2511,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -2523,7 +2523,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -2535,7 +2535,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -2547,7 +2547,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -2559,7 +2559,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"], "maxLength": 22 } @@ -2572,7 +2572,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"], "maxLength": 22 } @@ -2585,7 +2585,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -2597,7 +2597,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -2610,7 +2610,7 @@ "name": "PostCheckoutSessionsBodyPaymentIntentDataShippingAddress", "type": "named" }, - "rest": { + "http": { "type": ["object"] } }, @@ -2622,7 +2622,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"], "maxLength": 5000 } @@ -2632,7 +2632,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "type": ["string"], "maxLength": 5000 } @@ -2645,7 +2645,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"], "maxLength": 5000 } @@ -2658,7 +2658,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"], "maxLength": 5000 } @@ -2675,7 +2675,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"], "maxLength": 5000 } @@ -2688,7 +2688,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"], "maxLength": 5000 } @@ -2698,7 +2698,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "type": ["string"], "maxLength": 5000 } @@ -2711,7 +2711,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"], "maxLength": 5000 } @@ -2724,7 +2724,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"], "maxLength": 5000 } @@ -2737,7 +2737,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"], "maxLength": 5000 } @@ -2754,7 +2754,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } }, @@ -2763,7 +2763,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "type": ["string"] } } @@ -2780,7 +2780,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -2792,7 +2792,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -2804,7 +2804,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -2816,7 +2816,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -2828,7 +2828,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -2840,7 +2840,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -2852,7 +2852,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -2864,7 +2864,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -2876,7 +2876,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -2888,7 +2888,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -2900,7 +2900,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -2912,7 +2912,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -2924,7 +2924,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -2936,7 +2936,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -2948,7 +2948,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -2960,7 +2960,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -2972,7 +2972,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -2984,7 +2984,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -2996,7 +2996,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -3008,7 +3008,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -3020,7 +3020,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -3032,7 +3032,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -3044,7 +3044,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -3056,7 +3056,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -3068,7 +3068,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -3080,7 +3080,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -3092,7 +3092,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -3104,7 +3104,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -3116,7 +3116,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -3128,7 +3128,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } } @@ -3144,7 +3144,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -3156,7 +3156,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -3168,7 +3168,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -3180,7 +3180,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -3192,7 +3192,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -3208,7 +3208,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -3223,7 +3223,7 @@ "type": "array" } }, - "rest": { + "http": { "type": ["array"], "items": { "type": ["string"] @@ -3238,7 +3238,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"], "maxLength": 500 } @@ -3251,7 +3251,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -3263,7 +3263,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -3279,7 +3279,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -3295,7 +3295,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -3311,7 +3311,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -3327,7 +3327,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -3343,7 +3343,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -3359,7 +3359,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -3375,7 +3375,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } }, @@ -3387,7 +3387,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -3403,7 +3403,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -3415,7 +3415,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -3427,7 +3427,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -3439,7 +3439,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"], "maxLength": 22 } @@ -3452,7 +3452,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"], "maxLength": 17 } @@ -3469,7 +3469,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["boolean"] } } @@ -3485,7 +3485,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -3501,7 +3501,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -3513,7 +3513,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -3525,7 +3525,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -3541,7 +3541,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -3556,7 +3556,7 @@ "type": "array" } }, - "rest": { + "http": { "type": ["array"], "items": { "type": ["string"] @@ -3568,7 +3568,7 @@ "name": "PostCheckoutSessionsBodyPaymentMethodOptionsCustomerBalanceBankTransferType", "type": "named" }, - "rest": { + "http": { "type": ["string"] } } @@ -3581,7 +3581,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "type": ["string"], "maxLength": 5000 } @@ -3598,7 +3598,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -3614,7 +3614,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -3630,7 +3630,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -3646,7 +3646,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -3662,7 +3662,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -3678,7 +3678,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -3694,7 +3694,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } }, @@ -3706,7 +3706,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -3722,7 +3722,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -3738,7 +3738,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } }, @@ -3750,7 +3750,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -3766,7 +3766,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -3778,7 +3778,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["boolean"] } } @@ -3794,7 +3794,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -3810,7 +3810,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -3822,7 +3822,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -3834,7 +3834,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"], "maxLength": 127 } @@ -3847,7 +3847,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"], "maxLength": 32 } @@ -3860,7 +3860,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -3876,7 +3876,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } } @@ -3892,7 +3892,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -3908,7 +3908,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -3924,7 +3924,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -3940,7 +3940,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"], "maxLength": 5000 } @@ -3957,7 +3957,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -3969,7 +3969,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -3981,7 +3981,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -4000,7 +4000,7 @@ "type": "array" } }, - "rest": { + "http": { "type": ["array"], "items": { "type": ["string"], @@ -4019,7 +4019,7 @@ "type": "array" } }, - "rest": { + "http": { "type": ["array"], "items": { "type": ["string"] @@ -4038,7 +4038,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"], "maxLength": 5000 } @@ -4048,7 +4048,7 @@ "name": "CheckoutClient", "type": "named" }, - "rest": { + "http": { "type": ["string"] } }, @@ -4060,7 +4060,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -4074,7 +4074,7 @@ "name": "Boolean", "type": "named" }, - "rest": { + "http": { "type": ["boolean"] } } @@ -4091,7 +4091,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"], "maxLength": 1000 } @@ -4104,7 +4104,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -4116,7 +4116,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -4133,7 +4133,7 @@ }, "type": "array" }, - "rest": { + "http": { "type": ["array"], "items": { "type": ["string"] @@ -4152,7 +4152,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"], "maxLength": 5000 } @@ -4165,7 +4165,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } } @@ -4181,7 +4181,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -4190,7 +4190,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "type": ["string"], "maxLength": 100 } @@ -4203,7 +4203,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -4215,7 +4215,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -4227,7 +4227,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -4239,7 +4239,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -4251,7 +4251,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -4267,7 +4267,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -4279,7 +4279,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } } @@ -4292,7 +4292,7 @@ "name": "CheckoutUnit", "type": "named" }, - "rest": { + "http": { "type": ["string"] } }, @@ -4301,7 +4301,7 @@ "name": "Int32", "type": "named" }, - "rest": { + "http": { "type": ["integer"] } } @@ -4314,7 +4314,7 @@ "name": "CheckoutUnit", "type": "named" }, - "rest": { + "http": { "type": ["string"] } }, @@ -4323,7 +4323,7 @@ "name": "Int32", "type": "named" }, - "rest": { + "http": { "type": ["integer"] } } @@ -4336,7 +4336,7 @@ "name": "Int32", "type": "named" }, - "rest": { + "http": { "type": ["integer"] } }, @@ -4345,7 +4345,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "type": ["string"] } }, @@ -4357,7 +4357,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } } @@ -4374,7 +4374,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["number"] } }, @@ -4386,7 +4386,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "unix-time" } @@ -4402,7 +4402,7 @@ "type": "array" } }, - "rest": { + "http": { "type": ["array"], "items": { "type": ["string"], @@ -4418,7 +4418,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"], "maxLength": 500 } @@ -4431,7 +4431,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -4443,7 +4443,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -4455,7 +4455,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -4467,7 +4467,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -4479,7 +4479,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -4491,7 +4491,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "unix-time" } @@ -4504,7 +4504,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } }, @@ -4516,7 +4516,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } } @@ -4532,7 +4532,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } } @@ -4548,7 +4548,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -4557,7 +4557,7 @@ "name": "CheckoutType", "type": "named" }, - "rest": { + "http": { "type": ["string"] } } @@ -4573,7 +4573,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["number"] } }, @@ -4582,7 +4582,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "type": ["string"] } } @@ -4595,7 +4595,7 @@ "name": "PostCheckoutSessionsBodySubscriptionDataTrialSettingsEndBehavior", "type": "named" }, - "rest": { + "http": { "type": ["object"] } } @@ -4608,7 +4608,7 @@ "name": "CheckoutMissingPaymentMethod", "type": "named" }, - "rest": { + "http": { "type": ["string"] } } @@ -4622,7 +4622,7 @@ "name": "Boolean", "type": "named" }, - "rest": { + "http": { "type": ["boolean"] } } @@ -4642,7 +4642,7 @@ "type": "array" } }, - "rest": { + "http": { "type": ["array"], "items": { "type": ["string"], @@ -4661,7 +4661,7 @@ "type": "array" } }, - "rest": { + "http": { "type": ["array"], "items": { "type": ["string"], @@ -4675,7 +4675,7 @@ "name": "Binary", "type": "named" }, - "rest": { + "http": { "type": ["string"], "format": "binary" } @@ -4689,7 +4689,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -4699,7 +4699,7 @@ "name": "FilesPurpose", "type": "named" }, - "rest": { + "http": { "type": ["string"] } } @@ -4713,7 +4713,7 @@ "name": "Boolean", "type": "named" }, - "rest": { + "http": { "type": ["boolean"] } }, @@ -4725,7 +4725,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "unix-time" } @@ -4738,7 +4738,7 @@ "type": "named" } }, - "rest": { + "http": { "type": null } } @@ -4758,7 +4758,7 @@ "type": "array" } }, - "rest": { + "http": { "type": ["array"], "items": { "type": ["string"], @@ -4775,7 +4775,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } } @@ -4792,7 +4792,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -4808,7 +4808,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -4820,7 +4820,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } } @@ -4836,7 +4836,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["boolean"] } }, @@ -4848,7 +4848,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "int64" } @@ -4861,7 +4861,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "int64" } @@ -4874,7 +4874,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "int32" } @@ -4887,7 +4887,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"], "format": "date-time" } @@ -4901,7 +4901,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -4917,7 +4917,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "int64" } @@ -4930,7 +4930,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -4945,7 +4945,7 @@ "name": "Int32", "type": "named" }, - "rest": { + "http": { "type": ["integer"] } }, @@ -4955,7 +4955,7 @@ "name": "Boolean", "type": "named" }, - "rest": { + "http": { "type": ["boolean"] } }, @@ -4967,7 +4967,7 @@ "type": "named" } }, - "rest": { + "http": { "type": null } }, @@ -4977,7 +4977,7 @@ "name": "UnixTime", "type": "named" }, - "rest": { + "http": { "type": ["integer"], "format": "unix-time" } @@ -4988,7 +4988,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "type": ["string"] } }, @@ -5001,7 +5001,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"], "maxLength": 5000 } @@ -5015,7 +5015,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -5025,7 +5025,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "type": ["string"], "maxLength": 5000 } @@ -5039,7 +5039,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"], "maxLength": 5000 } @@ -5050,7 +5050,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "type": ["string"], "maxLength": 5000 } @@ -5061,7 +5061,7 @@ "name": "Boolean", "type": "named" }, - "rest": { + "http": { "type": ["boolean"] } }, @@ -5071,7 +5071,7 @@ "name": "JSON", "type": "named" }, - "rest": { + "http": { "type": ["object"] } }, @@ -5081,7 +5081,7 @@ "name": "TreasuryInboundTransferObject", "type": "named" }, - "rest": { + "http": { "type": ["string"] } }, @@ -5091,7 +5091,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "type": ["string"], "maxLength": 5000 } @@ -5105,7 +5105,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["boolean"] } }, @@ -5115,7 +5115,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "type": ["string"], "maxLength": 5000 } @@ -5126,7 +5126,7 @@ "name": "TreasuryInboundTransferStatus", "type": "named" }, - "rest": { + "http": { "type": ["string"] } }, @@ -5135,7 +5135,7 @@ "name": "TreasuryInboundTransfersResourceInboundTransferResourceStatusTransitions", "type": "named" }, - "rest": { + "http": { "type": ["object"] } }, @@ -5148,7 +5148,7 @@ "type": "named" } }, - "rest": { + "http": { "type": null } } @@ -5162,7 +5162,7 @@ "name": "TreasuryInboundTransfersResourceFailureDetailsCode", "type": "named" }, - "rest": { + "http": { "type": ["string"] } } @@ -5179,7 +5179,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "unix-time" } @@ -5193,7 +5193,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "unix-time" } @@ -5207,7 +5207,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "unix-time" } @@ -5224,7 +5224,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -5239,7 +5239,7 @@ "type": "array" } }, - "rest": { + "http": { "type": ["array"] } }, @@ -5254,7 +5254,7 @@ "type": "array" } }, - "rest": { + "http": { "type": ["array"], "items": { "type": ["string"] @@ -5269,7 +5269,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"], "format": "uuid" } @@ -5282,7 +5282,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"], "format": "binary" } @@ -5299,7 +5299,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -5311,7 +5311,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -5323,7 +5323,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "int64" } @@ -5336,7 +5336,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -5348,7 +5348,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -5360,7 +5360,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -5373,7 +5373,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "int32" } @@ -5386,7 +5386,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -5408,7 +5408,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "style": "simple", "name": "account", "in": "path", @@ -5528,7 +5528,7 @@ "type": "named" } }, - "rest": { + "http": { "in": "body" } } @@ -5589,7 +5589,7 @@ "name": "PostFilesBody", "type": "named" }, - "rest": { + "http": { "in": "body" } }, @@ -5598,7 +5598,7 @@ "name": "Int32", "type": "named" }, - "rest": { + "http": { "explode": false, "argumentName": "headerXRateLimitLimit", "schema": { @@ -5644,7 +5644,7 @@ "type": "named" } }, - "rest": { + "http": { "in": "body" } }, @@ -5653,7 +5653,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "style": "simple", "name": "id", "in": "path", @@ -5693,7 +5693,7 @@ "name": "Pet", "type": "named" }, - "rest": { + "http": { "in": "body" } } @@ -5737,7 +5737,7 @@ "name": "CreateFineTuningJobRequest", "type": "named" }, - "rest": { + "http": { "in": "body" } } @@ -5772,7 +5772,7 @@ "type": "array" } }, - "rest": { + "http": { "in": "body" } } @@ -5798,7 +5798,7 @@ "name": "Int64", "type": "named" }, - "rest": { + "http": { "name": "orderId", "in": "path", "schema": { @@ -5839,7 +5839,7 @@ "type": "named" } }, - "rest": { + "http": { "name": "api_key", "in": "header", "schema": { @@ -5853,7 +5853,7 @@ "name": "Int64", "type": "named" }, - "rest": { + "http": { "name": "petId", "in": "path", "schema": { @@ -5887,7 +5887,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "name": "username", "in": "path", "schema": { @@ -5926,7 +5926,7 @@ "type": "named" } }, - "rest": { + "http": { "in": "body" } } @@ -5960,7 +5960,7 @@ "name": "Pet", "type": "named" }, - "rest": { + "http": { "in": "body" } } @@ -5994,7 +5994,7 @@ "type": "named" } }, - "rest": { + "http": { "name": "name", "in": "query", "schema": { @@ -6008,7 +6008,7 @@ "name": "Int64", "type": "named" }, - "rest": { + "http": { "name": "petId", "in": "path", "schema": { @@ -6026,7 +6026,7 @@ "type": "named" } }, - "rest": { + "http": { "name": "status", "in": "query", "schema": { @@ -6070,7 +6070,7 @@ "type": "named" } }, - "rest": { + "http": { "name": "additionalMetadata", "in": "query", "schema": { @@ -6087,7 +6087,7 @@ "type": "named" } }, - "rest": { + "http": { "in": "body" } }, @@ -6097,7 +6097,7 @@ "name": "Int64", "type": "named" }, - "rest": { + "http": { "name": "petId", "in": "path", "schema": { @@ -6148,7 +6148,7 @@ "type": "named" } }, - "rest": { + "http": { "in": "body" } }, @@ -6158,7 +6158,7 @@ "name": "Int32", "type": "named" }, - "rest": { + "http": { "explode": false, "argumentName": "headerXRateLimitLimit", "schema": { diff --git a/ndc-rest-schema/openapi/testdata/petstore3/schema.json b/ndc-http-schema/openapi/testdata/petstore3/schema.json similarity index 100% rename from ndc-rest-schema/openapi/testdata/petstore3/schema.json rename to ndc-http-schema/openapi/testdata/petstore3/schema.json diff --git a/ndc-rest-schema/openapi/testdata/petstore3/source.json b/ndc-http-schema/openapi/testdata/petstore3/source.json similarity index 100% rename from ndc-rest-schema/openapi/testdata/petstore3/source.json rename to ndc-http-schema/openapi/testdata/petstore3/source.json diff --git a/ndc-rest-schema/openapi/testdata/prefix2/expected_multi_words.json b/ndc-http-schema/openapi/testdata/prefix2/expected_multi_words.json similarity index 93% rename from ndc-rest-schema/openapi/testdata/prefix2/expected_multi_words.json rename to ndc-http-schema/openapi/testdata/prefix2/expected_multi_words.json index 54797e1..40d61be 100644 --- a/ndc-rest-schema/openapi/testdata/prefix2/expected_multi_words.json +++ b/ndc-http-schema/openapi/testdata/prefix2/expected_multi_words.json @@ -1,5 +1,5 @@ { - "$schema": "https://raw.githubusercontent.com/hasura/ndc-rest/refs/heads/main/ndc-rest-schema/jsonschema/ndc-rest-schema.schema.json", + "$schema": "https://raw.githubusercontent.com/hasura/ndc-http/refs/heads/main/ndc-http-schema/jsonschema/ndc-http-schema.schema.json", "settings": { "servers": [ { @@ -30,7 +30,7 @@ "type": "named" } }, - "rest": { + "http": { "name": "id", "in": "query", "schema": { @@ -47,7 +47,7 @@ "type": "named" } }, - "rest": { + "http": { "name": "userId", "in": "query", "schema": { @@ -78,7 +78,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -90,7 +90,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "int64" } @@ -103,7 +103,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -115,7 +115,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "int64" } @@ -142,7 +142,7 @@ "name": "Post", "type": "named" }, - "rest": { + "http": { "in": "body", "schema": { "type": ["object"] diff --git a/ndc-rest-schema/openapi/testdata/prefix2/expected_multi_words.schema.json b/ndc-http-schema/openapi/testdata/prefix2/expected_multi_words.schema.json similarity index 100% rename from ndc-rest-schema/openapi/testdata/prefix2/expected_multi_words.schema.json rename to ndc-http-schema/openapi/testdata/prefix2/expected_multi_words.schema.json diff --git a/ndc-rest-schema/openapi/testdata/prefix2/expected_single_word.json b/ndc-http-schema/openapi/testdata/prefix2/expected_single_word.json similarity index 93% rename from ndc-rest-schema/openapi/testdata/prefix2/expected_single_word.json rename to ndc-http-schema/openapi/testdata/prefix2/expected_single_word.json index 752be5f..4331cb9 100644 --- a/ndc-rest-schema/openapi/testdata/prefix2/expected_single_word.json +++ b/ndc-http-schema/openapi/testdata/prefix2/expected_single_word.json @@ -1,5 +1,5 @@ { - "$schema": "https://raw.githubusercontent.com/hasura/ndc-rest/refs/heads/main/ndc-rest-schema/jsonschema/ndc-rest-schema.schema.json", + "$schema": "https://raw.githubusercontent.com/hasura/ndc-http/refs/heads/main/ndc-http-schema/jsonschema/ndc-http-schema.schema.json", "settings": { "servers": [ { @@ -30,7 +30,7 @@ "type": "named" } }, - "rest": { + "http": { "name": "id", "in": "query", "schema": { @@ -47,7 +47,7 @@ "type": "named" } }, - "rest": { + "http": { "name": "userId", "in": "query", "schema": { @@ -78,7 +78,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -90,7 +90,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "int64" } @@ -103,7 +103,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -115,7 +115,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "int64" } @@ -142,7 +142,7 @@ "name": "Post", "type": "named" }, - "rest": { + "http": { "in": "body", "schema": { "type": ["object"] diff --git a/ndc-rest-schema/openapi/testdata/prefix2/expected_single_word.schema.json b/ndc-http-schema/openapi/testdata/prefix2/expected_single_word.schema.json similarity index 100% rename from ndc-rest-schema/openapi/testdata/prefix2/expected_single_word.schema.json rename to ndc-http-schema/openapi/testdata/prefix2/expected_single_word.schema.json diff --git a/ndc-rest-schema/openapi/testdata/prefix2/source.json b/ndc-http-schema/openapi/testdata/prefix2/source.json similarity index 97% rename from ndc-rest-schema/openapi/testdata/prefix2/source.json rename to ndc-http-schema/openapi/testdata/prefix2/source.json index 54e2ccc..53014c3 100644 --- a/ndc-rest-schema/openapi/testdata/prefix2/source.json +++ b/ndc-http-schema/openapi/testdata/prefix2/source.json @@ -1,7 +1,7 @@ { "swagger": "2.0", "info": { - "description": "Fake Online REST API for Testing and Prototyping", + "description": "Fake Online HTTP API for Testing and Prototyping", "version": "1.0.0", "title": "JSON Placeholder" }, diff --git a/ndc-rest-schema/openapi/testdata/prefix3/expected_multi_words.json b/ndc-http-schema/openapi/testdata/prefix3/expected_multi_words.json similarity index 94% rename from ndc-rest-schema/openapi/testdata/prefix3/expected_multi_words.json rename to ndc-http-schema/openapi/testdata/prefix3/expected_multi_words.json index fdc9ca6..a38dcdb 100644 --- a/ndc-rest-schema/openapi/testdata/prefix3/expected_multi_words.json +++ b/ndc-http-schema/openapi/testdata/prefix3/expected_multi_words.json @@ -1,5 +1,5 @@ { - "$schema": "https://raw.githubusercontent.com/hasura/ndc-rest/refs/heads/main/ndc-rest-schema/jsonschema/ndc-rest-schema.schema.json", + "$schema": "https://raw.githubusercontent.com/hasura/ndc-http/refs/heads/main/ndc-http-schema/jsonschema/ndc-http-schema.schema.json", "settings": { "servers": [ { @@ -50,7 +50,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "name": "app_id", "in": "query", "schema": { @@ -67,7 +67,7 @@ "type": "named" } }, - "rest": { + "http": { "name": "kind", "in": "query", "schema": { @@ -84,7 +84,7 @@ "type": "named" } }, - "rest": { + "http": { "name": "limit", "in": "query", "schema": { @@ -101,7 +101,7 @@ "type": "named" } }, - "rest": { + "http": { "name": "offset", "in": "query", "schema": { @@ -129,7 +129,7 @@ "type": "named" } }, - "rest": { + "http": { "type": null } }, @@ -141,7 +141,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -153,7 +153,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -165,7 +165,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } } @@ -182,7 +182,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } }, @@ -195,7 +195,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } }, @@ -208,7 +208,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } }, @@ -221,7 +221,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } }, @@ -234,7 +234,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } } @@ -248,7 +248,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "type": ["string"] } }, @@ -261,7 +261,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -271,7 +271,7 @@ "name": "FilterRelation", "type": "named" }, - "rest": { + "http": { "type": ["string"] } }, @@ -284,7 +284,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -300,7 +300,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -312,7 +312,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -325,7 +325,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -340,7 +340,7 @@ "type": "array" } }, - "rest": { + "http": { "type": ["array"] } }, @@ -352,7 +352,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -364,7 +364,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -376,7 +376,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"], "format": "date-time" } @@ -389,7 +389,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } } @@ -405,7 +405,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } }, @@ -420,7 +420,7 @@ "type": "array" } }, - "rest": { + "http": { "type": ["array"] } }, @@ -432,7 +432,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } }, @@ -444,7 +444,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } } @@ -461,7 +461,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "int64" } @@ -474,7 +474,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -487,7 +487,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } }, @@ -500,7 +500,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } }, @@ -515,7 +515,7 @@ "type": "array" } }, - "rest": { + "http": { "type": ["array"], "items": { "type": ["string"] @@ -531,7 +531,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } }, @@ -546,7 +546,7 @@ "type": "array" } }, - "rest": { + "http": { "type": ["array"] } }, @@ -558,7 +558,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -570,7 +570,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -585,7 +585,7 @@ "type": "array" } }, - "rest": { + "http": { "type": ["array"], "items": { "type": ["string"] @@ -603,7 +603,7 @@ "type": "array" } }, - "rest": { + "http": { "type": ["array"], "items": { "type": ["string"] @@ -621,7 +621,7 @@ "type": "array" } }, - "rest": { + "http": { "type": ["array"] } }, @@ -634,7 +634,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -647,7 +647,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "int64" } @@ -661,7 +661,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } }, @@ -674,7 +674,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } }, @@ -687,7 +687,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "int64" } @@ -700,7 +700,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -713,7 +713,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } }, @@ -725,7 +725,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -738,7 +738,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } } @@ -751,7 +751,7 @@ "name": "OutcomeDataAggregation", "type": "named" }, - "rest": { + "http": { "type": ["string"] } }, @@ -760,7 +760,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "type": ["string"] } }, @@ -769,7 +769,7 @@ "name": "Int32", "type": "named" }, - "rest": { + "http": { "type": ["integer"] } } @@ -786,7 +786,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -798,7 +798,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -810,7 +810,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -822,7 +822,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -834,7 +834,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -846,7 +846,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -858,7 +858,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -870,7 +870,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } } @@ -887,7 +887,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -918,7 +918,7 @@ "name": "NotificationInput", "type": "named" }, - "rest": { + "http": { "in": "body" } } diff --git a/ndc-rest-schema/openapi/testdata/prefix3/expected_multi_words.schema.json b/ndc-http-schema/openapi/testdata/prefix3/expected_multi_words.schema.json similarity index 100% rename from ndc-rest-schema/openapi/testdata/prefix3/expected_multi_words.schema.json rename to ndc-http-schema/openapi/testdata/prefix3/expected_multi_words.schema.json diff --git a/ndc-rest-schema/openapi/testdata/prefix3/expected_single_word.json b/ndc-http-schema/openapi/testdata/prefix3/expected_single_word.json similarity index 94% rename from ndc-rest-schema/openapi/testdata/prefix3/expected_single_word.json rename to ndc-http-schema/openapi/testdata/prefix3/expected_single_word.json index b3aa162..2ab09f7 100644 --- a/ndc-rest-schema/openapi/testdata/prefix3/expected_single_word.json +++ b/ndc-http-schema/openapi/testdata/prefix3/expected_single_word.json @@ -1,5 +1,5 @@ { - "$schema": "https://raw.githubusercontent.com/hasura/ndc-rest/refs/heads/main/ndc-rest-schema/jsonschema/ndc-rest-schema.schema.json", + "$schema": "https://raw.githubusercontent.com/hasura/ndc-http/refs/heads/main/ndc-http-schema/jsonschema/ndc-http-schema.schema.json", "settings": { "servers": [ { @@ -50,7 +50,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "name": "app_id", "in": "query", "schema": { @@ -67,7 +67,7 @@ "type": "named" } }, - "rest": { + "http": { "name": "kind", "in": "query", "schema": { @@ -84,7 +84,7 @@ "type": "named" } }, - "rest": { + "http": { "name": "limit", "in": "query", "schema": { @@ -101,7 +101,7 @@ "type": "named" } }, - "rest": { + "http": { "name": "offset", "in": "query", "schema": { @@ -129,7 +129,7 @@ "type": "named" } }, - "rest": { + "http": { "type": null } }, @@ -141,7 +141,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -153,7 +153,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -165,7 +165,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } } @@ -182,7 +182,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } }, @@ -195,7 +195,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } }, @@ -208,7 +208,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } }, @@ -221,7 +221,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } }, @@ -234,7 +234,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } } @@ -248,7 +248,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "type": ["string"] } }, @@ -261,7 +261,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -271,7 +271,7 @@ "name": "FilterRelation", "type": "named" }, - "rest": { + "http": { "type": ["string"] } }, @@ -284,7 +284,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -300,7 +300,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -312,7 +312,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -325,7 +325,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -340,7 +340,7 @@ "type": "array" } }, - "rest": { + "http": { "type": ["array"] } }, @@ -352,7 +352,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -364,7 +364,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -376,7 +376,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"], "format": "date-time" } @@ -389,7 +389,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } } @@ -405,7 +405,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } }, @@ -420,7 +420,7 @@ "type": "array" } }, - "rest": { + "http": { "type": ["array"] } }, @@ -432,7 +432,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } }, @@ -444,7 +444,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } } @@ -461,7 +461,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "int64" } @@ -474,7 +474,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -487,7 +487,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } }, @@ -500,7 +500,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } }, @@ -515,7 +515,7 @@ "type": "array" } }, - "rest": { + "http": { "type": ["array"], "items": { "type": ["string"] @@ -531,7 +531,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } }, @@ -546,7 +546,7 @@ "type": "array" } }, - "rest": { + "http": { "type": ["array"] } }, @@ -558,7 +558,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -570,7 +570,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -585,7 +585,7 @@ "type": "array" } }, - "rest": { + "http": { "type": ["array"], "items": { "type": ["string"] @@ -603,7 +603,7 @@ "type": "array" } }, - "rest": { + "http": { "type": ["array"], "items": { "type": ["string"] @@ -621,7 +621,7 @@ "type": "array" } }, - "rest": { + "http": { "type": ["array"] } }, @@ -634,7 +634,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -647,7 +647,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "int64" } @@ -661,7 +661,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } }, @@ -674,7 +674,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } }, @@ -687,7 +687,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"], "format": "int64" } @@ -700,7 +700,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -713,7 +713,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } }, @@ -725,7 +725,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } }, @@ -738,7 +738,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["integer"] } } @@ -751,7 +751,7 @@ "name": "OutcomeDataAggregation", "type": "named" }, - "rest": { + "http": { "type": ["string"] } }, @@ -760,7 +760,7 @@ "name": "String", "type": "named" }, - "rest": { + "http": { "type": ["string"] } }, @@ -769,7 +769,7 @@ "name": "Int32", "type": "named" }, - "rest": { + "http": { "type": ["integer"] } } @@ -786,7 +786,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -798,7 +798,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -810,7 +810,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -822,7 +822,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -834,7 +834,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -846,7 +846,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -858,7 +858,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } }, @@ -870,7 +870,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["object"] } } @@ -887,7 +887,7 @@ "type": "named" } }, - "rest": { + "http": { "type": ["string"] } } @@ -918,7 +918,7 @@ "name": "NotificationInput", "type": "named" }, - "rest": { + "http": { "in": "body" } } diff --git a/ndc-rest-schema/openapi/testdata/prefix3/expected_single_word.schema.json b/ndc-http-schema/openapi/testdata/prefix3/expected_single_word.schema.json similarity index 100% rename from ndc-rest-schema/openapi/testdata/prefix3/expected_single_word.schema.json rename to ndc-http-schema/openapi/testdata/prefix3/expected_single_word.schema.json diff --git a/ndc-rest-schema/openapi/testdata/prefix3/source.json b/ndc-http-schema/openapi/testdata/prefix3/source.json similarity index 100% rename from ndc-rest-schema/openapi/testdata/prefix3/source.json rename to ndc-http-schema/openapi/testdata/prefix3/source.json diff --git a/ndc-rest-schema/schema/auth.go b/ndc-http-schema/schema/auth.go similarity index 100% rename from ndc-rest-schema/schema/auth.go rename to ndc-http-schema/schema/auth.go diff --git a/ndc-http-schema/schema/constant.go b/ndc-http-schema/schema/constant.go new file mode 100644 index 0000000..80a5ee0 --- /dev/null +++ b/ndc-http-schema/schema/constant.go @@ -0,0 +1,9 @@ +package schema + +const ( + HTTPOptionsArgumentName string = "httpOptions" + HTTPSingleOptionsObjectName string = "HttpSingleOptions" + HTTPDistributedOptionsObjectName string = "HttpDistributedOptions" + HTTPServerIDScalarName string = "HttpServerId" + DistributedErrorObjectName string = "DistributedError" +) diff --git a/ndc-rest-schema/schema/enum.go b/ndc-http-schema/schema/enum.go similarity index 91% rename from ndc-rest-schema/schema/enum.go rename to ndc-http-schema/schema/enum.go index c47770b..b80e5c7 100644 --- a/ndc-rest-schema/schema/enum.go +++ b/ndc-http-schema/schema/enum.go @@ -56,41 +56,7 @@ func ParseSchemaSpecType(value string) (SchemaSpecType, error) { return result, nil } -// RequestType represents the request type enum -type RequestType string - -const ( - RequestTypeREST RequestType = "rest" -) - -var requestType_enums = []RequestType{RequestTypeREST} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *RequestType) UnmarshalJSON(b []byte) error { - var rawResult string - if err := json.Unmarshal(b, &rawResult); err != nil { - return err - } - - result, err := ParseRequestType(rawResult) - if err != nil { - return err - } - - *j = result - return nil -} - -// ParseRequestType parses RequestType from string -func ParseRequestType(value string) (RequestType, error) { - result := RequestType(value) - if !slices.Contains(requestType_enums, result) { - return result, fmt.Errorf("invalid RequestType. Expected %+v, got <%s>", schemaSpecType_enums, value) - } - return result, nil -} - -// SchemaFileFormat represents the file format enum for NDC REST schema file +// SchemaFileFormat represents the file format enum for NDC HTTP schema file type SchemaFileFormat string const ( diff --git a/ndc-rest-schema/schema/enum_test.go b/ndc-http-schema/schema/enum_test.go similarity index 85% rename from ndc-rest-schema/schema/enum_test.go rename to ndc-http-schema/schema/enum_test.go index b7353cb..9f1d635 100644 --- a/ndc-rest-schema/schema/enum_test.go +++ b/ndc-http-schema/schema/enum_test.go @@ -20,17 +20,6 @@ func TestSchemaSpecType(t *testing.T) { } } -func TestRequestType(t *testing.T) { - rawValue := "rest" - var got RequestType - if err := json.Unmarshal([]byte(fmt.Sprintf(`"%s"`, rawValue)), &got); err != nil { - t.Fatal(err.Error()) - } - if got != RequestType(rawValue) { - t.Fatalf("expected %s, got: %s", rawValue, got) - } -} - func TestSchemaFileFormat(t *testing.T) { rawValue := "yaml" var got SchemaFileFormat diff --git a/ndc-rest-schema/schema/schema.go b/ndc-http-schema/schema/schema.go similarity index 91% rename from ndc-rest-schema/schema/schema.go rename to ndc-http-schema/schema/schema.go index 75b2807..76a465a 100644 --- a/ndc-rest-schema/schema/schema.go +++ b/ndc-http-schema/schema/schema.go @@ -9,12 +9,12 @@ import ( "github.com/hasura/ndc-sdk-go/utils" ) -// NDCRestSchema extends the [NDC SchemaResponse] with OpenAPI REST information +// NDCHttpSchema extends the [NDC SchemaResponse] with OpenAPI HTTP information // // [NDC schema]: https://github.com/hasura/ndc-sdk-go/blob/1d3339db29e13a170aa8be5ff7fae8394cba0e49/schema/schema.generated.go#L887 -type NDCRestSchema struct { +type NDCHttpSchema struct { SchemaRef string `json:"$schema,omitempty" mapstructure:"$schema" yaml:"$schema,omitempty"` - Settings *NDCRestSettings `json:"settings,omitempty" mapstructure:"settings" yaml:"settings,omitempty"` + Settings *NDCHttpSettings `json:"settings,omitempty" mapstructure:"settings" yaml:"settings,omitempty"` // Functions (i.e. collections which return a single column and row) Functions map[string]OperationInfo `json:"functions" mapstructure:"functions" yaml:"functions"` @@ -30,11 +30,11 @@ type NDCRestSchema struct { ScalarTypes schema.SchemaResponseScalarTypes `json:"scalar_types" mapstructure:"scalar_types" yaml:"scalar_types"` } -// NewNDCRestSchema creates a NDCRestSchema instance -func NewNDCRestSchema() *NDCRestSchema { - return &NDCRestSchema{ - SchemaRef: "https://raw.githubusercontent.com/hasura/ndc-rest/refs/heads/main/ndc-rest-schema/jsonschema/ndc-rest-schema.schema.json", - Settings: &NDCRestSettings{}, +// NewNDCHttpSchema creates a NDCHttpSchema instance +func NewNDCHttpSchema() *NDCHttpSchema { + return &NDCHttpSchema{ + SchemaRef: "https://raw.githubusercontent.com/hasura/ndc-http/refs/heads/main/ndc-http-schema/jsonschema/ndc-http-schema.schema.json", + Settings: &NDCHttpSettings{}, Functions: map[string]OperationInfo{}, Procedures: map[string]OperationInfo{}, ObjectTypes: make(map[string]ObjectType), @@ -43,7 +43,7 @@ func NewNDCRestSchema() *NDCRestSchema { } // ToSchemaResponse converts the instance to NDC schema.SchemaResponse -func (ndc NDCRestSchema) ToSchemaResponse() *schema.SchemaResponse { +func (ndc NDCHttpSchema) ToSchemaResponse() *schema.SchemaResponse { functionKeys := utils.GetSortedKeys(ndc.Functions) functions := make([]schema.FunctionInfo, len(functionKeys)) for i, key := range functionKeys { @@ -71,7 +71,7 @@ func (ndc NDCRestSchema) ToSchemaResponse() *schema.SchemaResponse { } // GetFunction gets the NDC function by name -func (rm NDCRestSchema) GetFunction(name string) *OperationInfo { +func (rm NDCHttpSchema) GetFunction(name string) *OperationInfo { fn, ok := rm.Functions[name] if !ok { return nil @@ -81,7 +81,7 @@ func (rm NDCRestSchema) GetFunction(name string) *OperationInfo { } // GetProcedure gets the NDC procedure by name -func (rm NDCRestSchema) GetProcedure(name string) *OperationInfo { +func (rm NDCHttpSchema) GetProcedure(name string) *OperationInfo { fn, ok := rm.Procedures[name] if !ok { return nil @@ -104,7 +104,6 @@ type RuntimeSettings struct { // configure the request timeout in seconds, defau type Request struct { URL string `json:"url,omitempty" mapstructure:"url" yaml:"url,omitempty"` Method string `json:"method,omitempty" jsonschema:"enum=get,enum=post,enum=put,enum=patch,enum=delete" mapstructure:"method" yaml:"method,omitempty"` - Type RequestType `json:"type,omitempty" mapstructure:"type" yaml:"type,omitempty"` Headers map[string]utils.EnvString `json:"headers,omitempty" mapstructure:"headers" yaml:"headers,omitempty"` Security AuthSecurities `json:"security,omitempty" mapstructure:"security" yaml:"security,omitempty"` Servers []ServerConfig `json:"servers,omitempty" mapstructure:"servers" yaml:"servers,omitempty"` @@ -119,7 +118,6 @@ func (r Request) Clone() *Request { return &Request{ URL: r.URL, Method: r.Method, - Type: r.Type, Headers: r.Headers, Security: r.Security, Servers: r.Servers, @@ -216,7 +214,7 @@ type RequestBody struct { Encoding map[string]EncodingObject `json:"encoding,omitempty" mapstructure:"encoding" yaml:"encoding,omitempty"` } -// OperationInfo extends connector command operation with OpenAPI REST information +// OperationInfo extends connector command operation with OpenAPI HTTP information type OperationInfo struct { Request *Request `json:"request" mapstructure:"request" yaml:"request"` // Any arguments that this collection requires @@ -301,7 +299,7 @@ func (j OperationInfo) ProcedureSchema(name string) schema.ProcedureInfo { } } -// ObjectType represents the object type of rest schema +// ObjectType represents the object type of http schema type ObjectType struct { // Description of this type Description *string `json:"description,omitempty" mapstructure:"description,omitempty" yaml:"description,omitempty"` @@ -326,8 +324,8 @@ func (of ObjectType) Schema() schema.ObjectType { type ObjectField struct { schema.ObjectField `yaml:",inline"` - // The field schema information of the REST request - Rest *TypeSchema `json:"rest,omitempty" mapstructure:"rest" yaml:"rest,omitempty"` + // The field schema information of the HTTP request + HTTP *TypeSchema `json:"http,omitempty" mapstructure:"http" yaml:"http,omitempty"` } // Schema returns schema the object field @@ -365,23 +363,23 @@ func (j *ObjectField) UnmarshalJSON(b []byte) error { j.Arguments = arguments } - if rawType, ok := raw["rest"]; ok { + if rawType, ok := raw["http"]; ok { var ty TypeSchema if err := json.Unmarshal(rawType, &ty); err != nil { - return fmt.Errorf("field rest in ObjectField: %w", err) + return fmt.Errorf("field http in ObjectField: %w", err) } - j.Rest = &ty + j.HTTP = &ty } return nil } -// ArgumentInfo the information of REST request argument +// ArgumentInfo the information of HTTP request argument type ArgumentInfo struct { schema.ArgumentInfo `yaml:",inline"` - // The request parameter information of the REST request - Rest *RequestParameter `json:"rest,omitempty" mapstructure:"rest" yaml:"rest,omitempty"` + // The request parameter information of the HTTP request + HTTP *RequestParameter `json:"http,omitempty" mapstructure:"http" yaml:"http,omitempty"` } // UnmarshalJSON implements json.Unmarshaler. @@ -407,12 +405,12 @@ func (j *ArgumentInfo) UnmarshalJSON(b []byte) error { j.Description = &desc } - if rawParameter, ok := raw["rest"]; ok { + if rawParameter, ok := raw["http"]; ok { var param RequestParameter if err := json.Unmarshal(rawParameter, ¶m); err != nil { - return fmt.Errorf("field rest in ArgumentInfo: %w", err) + return fmt.Errorf("field http in ArgumentInfo: %w", err) } - j.Rest = ¶m + j.HTTP = ¶m } return nil diff --git a/ndc-rest-schema/schema/schema_test.go b/ndc-http-schema/schema/schema_test.go similarity index 95% rename from ndc-rest-schema/schema/schema_test.go rename to ndc-http-schema/schema/schema_test.go index c3d9ce6..8537873 100644 --- a/ndc-rest-schema/schema/schema_test.go +++ b/ndc-http-schema/schema/schema_test.go @@ -9,7 +9,7 @@ import ( "gotest.tools/v3/assert" ) -func TestDecodeRESTProcedureInfo(t *testing.T) { +func TestDecodeHTTPProcedureInfo(t *testing.T) { testCases := []struct { name string raw string @@ -52,7 +52,7 @@ func TestDecodeRESTProcedureInfo(t *testing.T) { } } -func TestDecodeRESTFunctionInfo(t *testing.T) { +func TestDecodeHTTPFunctionInfo(t *testing.T) { testCases := []struct { name string raw string @@ -72,7 +72,7 @@ func TestDecodeRESTFunctionInfo(t *testing.T) { "type": "nullable", "underlying_type": { "name": "Int", "type": "named" } }, - "rest": { + "http": { "name": "limit", "in": "query", "schema": { "type": ["integer"], "maximum": 100, "format": "int32", "nullable": true } @@ -97,7 +97,7 @@ func TestDecodeRESTFunctionInfo(t *testing.T) { Description: utils.ToPtr("How many items to return at one time (max 100)"), Type: schema.NewNullableNamedType("Int").Encode(), }, - Rest: &RequestParameter{ + HTTP: &RequestParameter{ Name: "limit", In: "query", Schema: &TypeSchema{ diff --git a/ndc-rest-schema/schema/setting.go b/ndc-http-schema/schema/setting.go similarity index 96% rename from ndc-rest-schema/schema/setting.go rename to ndc-http-schema/schema/setting.go index 7dda824..ce5b4c1 100644 --- a/ndc-rest-schema/schema/setting.go +++ b/ndc-http-schema/schema/setting.go @@ -10,8 +10,8 @@ import ( "github.com/hasura/ndc-sdk-go/utils" ) -// NDCRestSettings represent global settings of the REST API, including base URL, headers, etc... -type NDCRestSettings struct { +// NDCHttpSettings represent global settings of the HTTP API, including base URL, headers, etc... +type NDCHttpSettings struct { Servers []ServerConfig `json:"servers" mapstructure:"servers" yaml:"servers"` Headers map[string]utils.EnvString `json:"headers,omitempty" mapstructure:"headers" yaml:"headers,omitempty"` SecuritySchemes map[string]SecurityScheme `json:"securitySchemes,omitempty" mapstructure:"securitySchemes" yaml:"securitySchemes,omitempty"` @@ -22,15 +22,15 @@ type NDCRestSettings struct { } // UnmarshalJSON implements json.Unmarshaler. -func (j *NDCRestSettings) UnmarshalJSON(b []byte) error { - type Plain NDCRestSettings +func (j *NDCHttpSettings) UnmarshalJSON(b []byte) error { + type Plain NDCHttpSettings var raw Plain if err := json.Unmarshal(b, &raw); err != nil { return err } - result := NDCRestSettings(raw) + result := NDCHttpSettings(raw) _ = result.Validate() *j = result @@ -38,7 +38,7 @@ func (j *NDCRestSettings) UnmarshalJSON(b []byte) error { } // Validate if the current instance is valid -func (rs *NDCRestSettings) Validate() error { +func (rs *NDCHttpSettings) Validate() error { for _, server := range rs.Servers { if err := server.Validate(); err != nil { return err @@ -61,7 +61,7 @@ func (rs *NDCRestSettings) Validate() error { } // Validate if the current instance is valid -func (rs NDCRestSettings) GetHeaders() map[string]string { +func (rs NDCHttpSettings) GetHeaders() map[string]string { if rs.headers != nil { return rs.headers } diff --git a/ndc-rest-schema/schema/setting_test.go b/ndc-http-schema/schema/setting_test.go similarity index 96% rename from ndc-rest-schema/schema/setting_test.go rename to ndc-http-schema/schema/setting_test.go index 4cc1306..aab6e01 100644 --- a/ndc-rest-schema/schema/setting_test.go +++ b/ndc-http-schema/schema/setting_test.go @@ -10,11 +10,11 @@ import ( "gotest.tools/v3/assert" ) -func TestNDCRestSettings(t *testing.T) { +func TestNDCHttpSettings(t *testing.T) { testCases := []struct { name string input string - expected NDCRestSettings + expected NDCHttpSettings }{ { name: "setting_success", @@ -62,7 +62,7 @@ func TestNDCRestSettings(t *testing.T) { ], "version": "1.0.19" }`, - expected: NDCRestSettings{ + expected: NDCHttpSettings{ Servers: []ServerConfig{ { URL: utils.NewEnvString("PET_STORE_SERVER_URL", "https://petstore3.swagger.io/api/v3"), @@ -106,7 +106,7 @@ func TestNDCRestSettings(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - var result NDCRestSettings + var result NDCHttpSettings if err := json.Unmarshal([]byte(tc.input), &result); err != nil { t.Errorf("failed to decode: %s", err) t.FailNow() diff --git a/ndc-rest-schema/utils/file.go b/ndc-http-schema/utils/file.go similarity index 93% rename from ndc-rest-schema/utils/file.go rename to ndc-http-schema/utils/file.go index 89c43b9..9168f55 100644 --- a/ndc-rest-schema/utils/file.go +++ b/ndc-http-schema/utils/file.go @@ -15,11 +15,11 @@ import ( "slices" "strings" - "github.com/hasura/ndc-rest/ndc-rest-schema/schema" + "github.com/hasura/ndc-http/ndc-http-schema/schema" "gopkg.in/yaml.v3" ) -// MarshalSchema encodes the NDC REST schema to bytes +// MarshalSchema encodes the NDC HTTP schema to bytes func MarshalSchema(content any, format schema.SchemaFileFormat) ([]byte, error) { var fileBuffer bytes.Buffer switch format { @@ -28,13 +28,13 @@ func MarshalSchema(content any, format schema.SchemaFileFormat) ([]byte, error) encoder.SetIndent("", " ") if err := encoder.Encode(content); err != nil { - return nil, fmt.Errorf("failed to encode NDC REST schema: %w", err) + return nil, fmt.Errorf("failed to encode NDC HTTP schema: %w", err) } case schema.SchemaFileYAML: encoder := yaml.NewEncoder(&fileBuffer) encoder.SetIndent(2) if err := encoder.Encode(content); err != nil { - return nil, fmt.Errorf("failed to encode NDC REST schema: %w", err) + return nil, fmt.Errorf("failed to encode NDC HTTP schema: %w", err) } default: return nil, errors.New("invalid schema file format. Accept json or yaml") @@ -43,7 +43,7 @@ func MarshalSchema(content any, format schema.SchemaFileFormat) ([]byte, error) return fileBuffer.Bytes(), nil } -// WriteSchemaFile writes the NDC REST schema to file +// WriteSchemaFile writes the NDC HTTP schema to file func WriteSchemaFile(outputPath string, content any) error { format, err := schema.ParseSchemaFileFormat(strings.TrimLeft(filepath.Ext(outputPath), ".")) if err != nil { diff --git a/ndc-rest-schema/utils/patch.go b/ndc-http-schema/utils/patch.go similarity index 93% rename from ndc-rest-schema/utils/patch.go rename to ndc-http-schema/utils/patch.go index 1416122..446248c 100644 --- a/ndc-rest-schema/utils/patch.go +++ b/ndc-http-schema/utils/patch.go @@ -7,7 +7,7 @@ import ( "strings" jsonpatch "github.com/evanphx/json-patch" - "github.com/hasura/ndc-rest/ndc-rest-schema/schema" + "github.com/hasura/ndc-http/ndc-http-schema/schema" "gopkg.in/yaml.v3" ) @@ -36,8 +36,8 @@ type PatchConfig struct { Strategy PatchStrategy `json:"strategy" jsonschema:"enum=merge,enum=json6902" yaml:"strategy"` } -// ApplyPatchToRestSchema applies JSON patches to NDC rest schema and validate the output -func ApplyPatchToRestSchema(input *schema.NDCRestSchema, patchFiles []PatchConfig) (*schema.NDCRestSchema, error) { +// ApplyPatchToHTTPSchema applies JSON patches to NDC HTTP schema and validate the output +func ApplyPatchToHTTPSchema(input *schema.NDCHttpSchema, patchFiles []PatchConfig) (*schema.NDCHttpSchema, error) { if len(patchFiles) == 0 { return input, nil } @@ -51,7 +51,7 @@ func ApplyPatchToRestSchema(input *schema.NDCRestSchema, patchFiles []PatchConfi return nil, err } - var result schema.NDCRestSchema + var result schema.NDCHttpSchema if err := json.Unmarshal(rawResult, &result); err != nil { return nil, err } diff --git a/ndc-rest-schema/utils/patch_test.go b/ndc-http-schema/utils/patch_test.go similarity index 100% rename from ndc-rest-schema/utils/patch_test.go rename to ndc-http-schema/utils/patch_test.go diff --git a/ndc-rest-schema/utils/slice.go b/ndc-http-schema/utils/slice.go similarity index 100% rename from ndc-rest-schema/utils/slice.go rename to ndc-http-schema/utils/slice.go diff --git a/ndc-rest-schema/utils/string.go b/ndc-http-schema/utils/string.go similarity index 100% rename from ndc-rest-schema/utils/string.go rename to ndc-http-schema/utils/string.go diff --git a/ndc-rest-schema/utils/testdata/patch/expected.json b/ndc-http-schema/utils/testdata/patch/expected.json similarity index 100% rename from ndc-rest-schema/utils/testdata/patch/expected.json rename to ndc-http-schema/utils/testdata/patch/expected.json diff --git a/ndc-rest-schema/utils/testdata/patch/patches/1-merge.json b/ndc-http-schema/utils/testdata/patch/patches/1-merge.json similarity index 100% rename from ndc-rest-schema/utils/testdata/patch/patches/1-merge.json rename to ndc-http-schema/utils/testdata/patch/patches/1-merge.json diff --git a/ndc-rest-schema/utils/testdata/patch/patches/2-json6902.yaml b/ndc-http-schema/utils/testdata/patch/patches/2-json6902.yaml similarity index 100% rename from ndc-rest-schema/utils/testdata/patch/patches/2-json6902.yaml rename to ndc-http-schema/utils/testdata/patch/patches/2-json6902.yaml diff --git a/ndc-rest-schema/utils/testdata/patch/source.json b/ndc-http-schema/utils/testdata/patch/source.json similarity index 100% rename from ndc-rest-schema/utils/testdata/patch/source.json rename to ndc-http-schema/utils/testdata/patch/source.json diff --git a/ndc-rest-schema/version/version.go b/ndc-http-schema/version/version.go similarity index 100% rename from ndc-rest-schema/version/version.go rename to ndc-http-schema/version/version.go diff --git a/ndc-rest-schema/schema/constant.go b/ndc-rest-schema/schema/constant.go deleted file mode 100644 index edf128d..0000000 --- a/ndc-rest-schema/schema/constant.go +++ /dev/null @@ -1,9 +0,0 @@ -package schema - -const ( - RESTOptionsArgumentName string = "restOptions" - RESTSingleOptionsObjectName string = "RestSingleOptions" - RESTDistributedOptionsObjectName string = "RestDistributedOptions" - RESTServerIDScalarName string = "RestServerId" - DistributedErrorObjectName string = "DistributedError" -) diff --git a/scripts/build-manifest.sh b/scripts/build-manifest.sh index 3327163..6b28f68 100755 --- a/scripts/build-manifest.sh +++ b/scripts/build-manifest.sh @@ -3,7 +3,7 @@ set -evo pipefail REF=$(git rev-parse --short HEAD) VERSION=${VERSION:-$REF} -BUILD_DIR=/tmp/ndc-rest +BUILD_DIR=/tmp/ndc-http ROOT="$(pwd)" rm -rf $BUILD_DIR diff --git a/scripts/test.sh b/scripts/test.sh index c537b36..9bdd347 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -32,8 +32,8 @@ http_wait() { exit 1 } -go build -o ./tmp/ndc-rest ./server -./tmp/ndc-rest serve --configuration $CONFIG_PATH > /dev/null 2>&1 & +go build -o ./tmp/ndc-http ./server +./tmp/ndc-http serve --configuration $CONFIG_PATH > /dev/null 2>&1 & serverPID=$! http_wait http://localhost:8080/health diff --git a/server/main.go b/server/main.go index 6d3e3f7..2e9b806 100644 --- a/server/main.go +++ b/server/main.go @@ -1,7 +1,7 @@ package main import ( - rest "github.com/hasura/ndc-rest/connector" + rest "github.com/hasura/ndc-http/connector" "github.com/hasura/ndc-sdk-go/connector" ) @@ -14,9 +14,9 @@ import ( // [NDC Go SDK]: https://github.com/hasura/ndc-sdk-go func main() { if err := rest.Start( - rest.NewRESTConnector(), - connector.WithMetricsPrefix("ndc_rest"), - connector.WithDefaultServiceName("ndc_rest"), + rest.NewHTTPConnector(), + connector.WithMetricsPrefix("ndc_http"), + connector.WithDefaultServiceName("ndc_http"), ); err != nil { panic(err) } diff --git a/tests/configuration/config.yaml b/tests/configuration/config.yaml index 22b1f10..e169fa2 100644 --- a/tests/configuration/config.yaml +++ b/tests/configuration/config.yaml @@ -1,4 +1,4 @@ -# yaml-language-server: $schema=../../ndc-rest-schema/jsonschema/configuration.schema.json +# yaml-language-server: $schema=../../ndc-http-schema/jsonschema/configuration.schema.json output: schema.output.json strict: true forwardHeaders: @@ -13,7 +13,7 @@ forwardHeaders: concurrency: query: 1 mutation: 1 - rest: 0 + http: 0 files: - - file: https://raw.githubusercontent.com/hasura/ndc-rest/refs/heads/main/connector/testdata/jsonplaceholder/swagger.json + - file: https://raw.githubusercontent.com/hasura/ndc-http/refs/heads/main/connector/testdata/jsonplaceholder/swagger.json spec: oas2