-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
111 changed files
with
6,482 additions
and
3,977 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ name: Release container definition | |
on: | ||
push: | ||
tags: | ||
- "*" | ||
- "v*" | ||
|
||
env: | ||
DOCKER_REGISTRY: ghcr.io | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,4 +27,5 @@ go.work.sum | |
|
||
# Release directory | ||
release/ | ||
_output/ | ||
_output/ | ||
schema.output.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
include: | ||
- tests/engine/compose.yaml | ||
services: | ||
ndc-rest: | ||
build: | ||
context: . | ||
ports: | ||
- 8080:8080 | ||
volumes: | ||
- ./tests/configuration:/etc/connector:ro | ||
extra_hosts: | ||
- local.hasura.dev=host-gateway | ||
environment: | ||
OTEL_EXPORTER_OTLP_ENDPOINT: http://local.hasura.dev:4317 | ||
HASURA_LOG_LEVEL: debug |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,21 @@ | ||
# yaml-language-server: $schema=https://raw.githubusercontent.com/hasura/ndc-rest-schema/main/jsonschema/configuration.schema.json | ||
output: schema.output.json | ||
strict: true | ||
forwardHeaders: | ||
enabled: false | ||
argumentField: headers | ||
responseHeaders: null | ||
concurrency: | ||
query: 1 | ||
mutation: 1 | ||
rest: 5 | ||
files: | ||
- file: https://raw.githubusercontent.com/hasura/ndc-rest/main/connector/testdata/jsonplaceholder/swagger.json | ||
spec: openapi2 | ||
spec: oas2 | ||
timeout: | ||
value: 30 | ||
retry: | ||
times: | ||
value: 1 | ||
delay: | ||
value: 500 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,10 @@ | ||
package rest | ||
|
||
import ( | ||
"context" | ||
"log/slog" | ||
"os" | ||
"strings" | ||
|
||
"github.com/hasura/ndc-rest/ndc-rest-schema/command" | ||
"github.com/hasura/ndc-sdk-go/connector" | ||
"github.com/lmittmann/tint" | ||
) | ||
|
||
// CLI extends the NDC SDK with custom commands | ||
type CLI struct { | ||
connector.ServeCLI | ||
Convert command.ConvertCommandArguments `cmd:"" help:"Convert API spec to NDC schema. For example:\n ndc-rest-schema convert -f petstore.yaml -o petstore.json"` | ||
} | ||
|
||
// Execute executes custom commands | ||
func (c CLI) Execute(ctx context.Context, cmd string) error { | ||
switch cmd { | ||
case "convert": | ||
var logLevel slog.Level | ||
err := logLevel.UnmarshalText([]byte(strings.ToUpper(c.LogLevel))) | ||
if err != nil { | ||
return err | ||
} | ||
logger := slog.New(tint.NewHandler(os.Stderr, &tint.Options{ | ||
Level: logLevel, | ||
TimeFormat: "15:04", | ||
})) | ||
|
||
return command.CommandConvertToNDCSchema(&c.Convert, logger) | ||
default: | ||
return c.ServeCLI.Execute(ctx, cmd) | ||
} | ||
} | ||
|
||
// Start wrap the connector.Start function with custom CLI | ||
// Start and serve the connector API server | ||
func Start[Configuration, State any](restConnector connector.Connector[Configuration, State], options ...connector.ServeOption) error { | ||
var cli CLI | ||
return connector.StartCustom[Configuration, State](&cli, restConnector, options...) | ||
return connector.Start(restConnector, options...) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.