From 2d07bd08f33b8256843ff0ae04f308f9f8796310 Mon Sep 17 00:00:00 2001 From: Domenico Andreoli Date: Thu, 20 Apr 2023 11:29:06 +0200 Subject: [PATCH] Add openapi spec --- .github/workflows/main.yml | 3 + .license_ignore | 2 + Makefile | 10 +- docs/api-spec.html | 337 +++++++++++++++++++++++++++++++++++++ docs/api-spec.yaml | 68 ++++++++ 5 files changed, 419 insertions(+), 1 deletion(-) create mode 100644 docs/api-spec.html create mode 100644 docs/api-spec.yaml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2b9c0e38..7627a7cb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -47,6 +47,9 @@ jobs: - name: Lint code run: make lint + - name: Check docs + run: make docs + - name: Run unit tests env: TEST_SCHEMA_URI: "./etc/ecs-8.2.0.tar.gz" diff --git a/.license_ignore b/.license_ignore index ac3e4997..afe3bfb2 100644 --- a/.license_ignore +++ b/.license_ignore @@ -15,6 +15,8 @@ requirements.txt runtime.txt setup.cfg +docs/api-spec.html + scripts/generate-alerts.sh scripts/generate-network-events.sh diff --git a/Makefile b/Makefile index 2c4c5316..e3b2786f 100644 --- a/Makefile +++ b/Makefile @@ -21,6 +21,8 @@ else embed-python := $(error Embedding Python is not supported on this system) endif +REDOCLY := npx -y @redocly/cli + rwildcard=$(foreach d,$(wildcard $(1:=/*)),$(call rwildcard,$d,$2) $(filter $(subst *,%,$2),$d)) all: lint tests @@ -35,6 +37,7 @@ prereq-go: prereq-py lint: $(PYTHON) -m black -q --check geneve tests || ($(PYTHON) -m black geneve tests; false) $(PYTHON) -m isort -q --check geneve tests || ($(PYTHON) -m isort geneve tests; false) + $(REDOCLY) lint docs/api-spec.yaml license-check: bash scripts/license_check.sh @@ -95,6 +98,11 @@ package: pkg-build $(MAKE) pkg-install VENV=$(VENV) rm -rf $(VENV) +docs/api-spec.html: docs/api-spec.yaml + $(REDOCLY) build-docs --output $@ $< + +docs: docs/api-spec.html + CREDS_FILE=credentials-cloud-stack.json cloud-stack-up: @@ -138,4 +146,4 @@ override TEST_STACK_VERSION := $(shell \ ) endif -.PHONY: lint tests online_tests run up down +.PHONY: docs lint tests online_tests run up down diff --git a/docs/api-spec.html b/docs/api-spec.html new file mode 100644 index 00000000..37eb4fcc --- /dev/null +++ b/docs/api-spec.html @@ -0,0 +1,337 @@ + + + + + + Geneve + + + + + + + + + +

Geneve (0.2.0)

Download OpenAPI specification:Download

Domenico Andreoli: domenico.andreoli@elastic.co

Geneve REST API

+

info

get-status

Return server status

+

Responses

schema

create-schema

Create a new schema

+
path Parameters
name
required
string
Request Body schema: text/plain
object (schema)

Responses

+ + + + diff --git a/docs/api-spec.yaml b/docs/api-spec.yaml new file mode 100644 index 00000000..8e34def2 --- /dev/null +++ b/docs/api-spec.yaml @@ -0,0 +1,68 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +openapi: "3.0.0" +info: + title: Geneve + description: Geneve REST API + version: 0.2.0 + contact: + name: Domenico Andreoli + email: domenico.andreoli@elastic.co +servers: + - url: http://localhost:9256/api + description: Geneve +paths: + "/status": + get: + tags: ["info"] + description: Return server status + operationId: get-status + responses: + "200": + description: A source is returned + content: + text/plain: + schema: + type: string + properties: {} + "/schema/{name}": + parameters: + - name: name + in: path + required: true + schema: + type: string + put: + tags: ["schema"] + description: Create a new schema + operationId: create-schema + requestBody: + content: + text/plain: + schema: + $ref: "#/components/schemas/schema" + responses: + "200": + description: pippo +tags: + - name: info + - name: schema +components: + schemas: + schema: + type: object