initial commit
This commit is contained in:
commit
88c14b627e
224 files changed
+17204
No files matched your search
@@ -0,0 +1,2 @@
|
||||
/.venv-codegen/
|
||||
/node_modules/
|
||||
@@ -0,0 +1,4 @@
|
||||
**/components/schemas.yml
|
||||
**/*.bundle.yml
|
||||
node_modules
|
||||
.venv-codegen
|
||||
@@ -0,0 +1,58 @@
|
||||
SHELL := /usr/bin/env bash
|
||||
.DEFAULT_GOAL := help
|
||||
|
||||
API_DIR := $(CURDIR)
|
||||
ROOT_DIR := $(abspath $(API_DIR)/..)
|
||||
CODEGEN_PYTHON ?= $(API_DIR)/.venv-codegen/bin/python
|
||||
BOOTSTRAP_PYTHON ?= python3
|
||||
REDOCLY ?= $(API_DIR)/node_modules/.bin/redocly
|
||||
|
||||
##@ API contracts
|
||||
|
||||
.PHONY: install
|
||||
install: ## Install pinned OpenAPI tooling
|
||||
@if [ ! -x "$(CODEGEN_PYTHON)" ]; then $(BOOTSTRAP_PYTHON) -m venv "$(API_DIR)/.venv-codegen"; fi
|
||||
"$(CODEGEN_PYTHON)" -m pip install --disable-pip-version-check -r "$(ROOT_DIR)/scripts/requirements-codegen.txt"
|
||||
npm ci --prefix "$(API_DIR)" --ignore-scripts --no-audit --no-fund
|
||||
|
||||
.PHONY: bundle
|
||||
bundle: ## Merge split schemas and create public and ML bundles
|
||||
"$(CODEGEN_PYTHON)" "$(ROOT_DIR)/scripts/merge-schemas.py" "$(API_DIR)/core"
|
||||
"$(CODEGEN_PYTHON)" "$(ROOT_DIR)/scripts/merge-schemas.py" "$(API_DIR)/ml"
|
||||
"$(REDOCLY)" bundle "$(API_DIR)/core/openapi.yml" --output "$(API_DIR)/core/openapi.bundle.yml"
|
||||
"$(REDOCLY)" bundle "$(API_DIR)/ml/openapi.yml" --output "$(API_DIR)/ml/openapi.bundle.yml"
|
||||
|
||||
.PHONY: lint
|
||||
lint: bundle ## Lint both bundled contracts
|
||||
"$(REDOCLY)" lint --config "$(API_DIR)/redocly.yaml" "$(API_DIR)/core/openapi.bundle.yml"
|
||||
"$(REDOCLY)" lint --config "$(API_DIR)/redocly.yaml" "$(API_DIR)/ml/openapi.bundle.yml"
|
||||
|
||||
.PHONY: check
|
||||
check: lint ## Build and lint both contract bundles
|
||||
PYTHONDONTWRITEBYTECODE=1 "$(CODEGEN_PYTHON)" -m unittest discover -s "$(ROOT_DIR)/scripts" -p 'test_merge_schemas.py'
|
||||
|
||||
.PHONY: check-compat
|
||||
check-compat: bundle ## Compare the public contract with API_BASE_REF
|
||||
API_BASE_REF="$(API_BASE_REF)" REDOCLY="$(REDOCLY)" CODEGEN_PYTHON="$(CODEGEN_PYTHON)" bash "$(ROOT_DIR)/scripts/check-api-compat.sh"
|
||||
|
||||
.PHONY: check-toolchain
|
||||
check-toolchain: ## Check OpenAPI 3.2.0 support and generated validation behavior
|
||||
"$(REDOCLY)" lint --config "$(API_DIR)/redocly.yaml" "$(API_DIR)/testdata/openapi-3.2.0.yml"
|
||||
$(MAKE) -C "$(ROOT_DIR)/backend" check-ogen-compat
|
||||
|
||||
.PHONY: fmt
|
||||
fmt: ## Format handwritten OpenAPI YAML files
|
||||
"$(API_DIR)/node_modules/.bin/prettier" --write "$(API_DIR)/**/*.yml" "$(API_DIR)/redocly.yaml"
|
||||
|
||||
.PHONY: fmt-check
|
||||
fmt-check: ## Check OpenAPI YAML formatting
|
||||
"$(API_DIR)/node_modules/.bin/prettier" --check "$(API_DIR)/**/*.yml" "$(API_DIR)/redocly.yaml"
|
||||
|
||||
.PHONY: verify
|
||||
verify: check check-toolchain ## Run contract lint and generator compatibility checks
|
||||
|
||||
##@ Help
|
||||
|
||||
.PHONY: help
|
||||
help: ## Show available targets
|
||||
@awk 'BEGIN{FS=":.*##"; printf "\nUsage:\n make -C api <target>\n"} /^[a-zA-Z0-9_-]+:.*##/ {printf " %-16s %s\n", $$1, $$2} /^##@/ {printf "\n%s\n", substr($$0, 5)}' $(MAKEFILE_LIST)
|
||||
@@ -0,0 +1,10 @@
|
||||
HealthResponse:
|
||||
type: object
|
||||
additionalProperties: false
|
||||
required:
|
||||
- status
|
||||
properties:
|
||||
status:
|
||||
type: string
|
||||
enum:
|
||||
- ok
|
||||
@@ -0,0 +1,11 @@
|
||||
schemas:
|
||||
HealthResponse:
|
||||
type: object
|
||||
additionalProperties: false
|
||||
required:
|
||||
- status
|
||||
properties:
|
||||
status:
|
||||
type: string
|
||||
enum:
|
||||
- ok
|
||||
@@ -0,0 +1,33 @@
|
||||
openapi: 3.2.0
|
||||
info:
|
||||
title: Lincodex API
|
||||
version: 0.1.0
|
||||
servers:
|
||||
- url: /
|
||||
paths:
|
||||
/api/v1/healthz:
|
||||
get:
|
||||
operationId: GetHealthz
|
||||
summary: Check whether the API process is responding.
|
||||
security: []
|
||||
tags:
|
||||
- health
|
||||
responses:
|
||||
'200':
|
||||
description: The API process is responding.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/HealthResponse'
|
||||
components:
|
||||
schemas:
|
||||
HealthResponse:
|
||||
type: object
|
||||
additionalProperties: false
|
||||
required:
|
||||
- status
|
||||
properties:
|
||||
status:
|
||||
type: string
|
||||
enum:
|
||||
- ok
|
||||
@@ -0,0 +1,9 @@
|
||||
openapi: 3.2.0
|
||||
info:
|
||||
title: Lincodex API
|
||||
version: 0.1.0
|
||||
servers:
|
||||
- url: /
|
||||
paths:
|
||||
/api/v1/healthz:
|
||||
$ref: ./routes/healthz.yml
|
||||
@@ -0,0 +1,13 @@
|
||||
get:
|
||||
operationId: GetHealthz
|
||||
summary: Check whether the API process is responding.
|
||||
security: []
|
||||
tags:
|
||||
- health
|
||||
responses:
|
||||
"200":
|
||||
description: The API process is responding.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: ../components/schemas.yml#/HealthResponse
|
||||
@@ -0,0 +1,21 @@
|
||||
MLHealthResponse:
|
||||
type: object
|
||||
additionalProperties: false
|
||||
required:
|
||||
- status
|
||||
properties:
|
||||
status:
|
||||
type: string
|
||||
enum:
|
||||
- ok
|
||||
MLReadinessResponse:
|
||||
type: object
|
||||
additionalProperties: false
|
||||
required:
|
||||
- status
|
||||
properties:
|
||||
status:
|
||||
type: string
|
||||
enum:
|
||||
- ready
|
||||
- not_ready
|
||||
@@ -0,0 +1,11 @@
|
||||
schemas:
|
||||
MLHealthResponse:
|
||||
type: object
|
||||
additionalProperties: false
|
||||
required:
|
||||
- status
|
||||
properties:
|
||||
status:
|
||||
type: string
|
||||
enum:
|
||||
- ok
|
||||
@@ -0,0 +1,12 @@
|
||||
schemas:
|
||||
MLReadinessResponse:
|
||||
type: object
|
||||
additionalProperties: false
|
||||
required:
|
||||
- status
|
||||
properties:
|
||||
status:
|
||||
type: string
|
||||
enum:
|
||||
- ready
|
||||
- not_ready
|
||||
@@ -0,0 +1,64 @@
|
||||
openapi: 3.2.0
|
||||
info:
|
||||
title: Lincodex ML Operational API
|
||||
version: 0.1.0
|
||||
servers:
|
||||
- url: /
|
||||
paths:
|
||||
/healthz:
|
||||
get:
|
||||
operationId: GetMLHealthz
|
||||
summary: Check whether the ML process is responding.
|
||||
security: []
|
||||
tags:
|
||||
- health
|
||||
responses:
|
||||
'200':
|
||||
description: The ML process is responding.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/MLHealthResponse'
|
||||
/readyz:
|
||||
get:
|
||||
operationId: GetMLReadyz
|
||||
summary: Check whether an inference runtime is available.
|
||||
security: []
|
||||
tags:
|
||||
- health
|
||||
responses:
|
||||
'200':
|
||||
description: An inference runtime is available.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/MLReadinessResponse'
|
||||
'503':
|
||||
description: No inference runtime is available.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/MLReadinessResponse'
|
||||
components:
|
||||
schemas:
|
||||
MLHealthResponse:
|
||||
type: object
|
||||
additionalProperties: false
|
||||
required:
|
||||
- status
|
||||
properties:
|
||||
status:
|
||||
type: string
|
||||
enum:
|
||||
- ok
|
||||
MLReadinessResponse:
|
||||
type: object
|
||||
additionalProperties: false
|
||||
required:
|
||||
- status
|
||||
properties:
|
||||
status:
|
||||
type: string
|
||||
enum:
|
||||
- ready
|
||||
- not_ready
|
||||
@@ -0,0 +1,11 @@
|
||||
openapi: 3.2.0
|
||||
info:
|
||||
title: Lincodex ML Operational API
|
||||
version: 0.1.0
|
||||
servers:
|
||||
- url: /
|
||||
paths:
|
||||
/healthz:
|
||||
$ref: ./routes/healthz.yml
|
||||
/readyz:
|
||||
$ref: ./routes/readyz.yml
|
||||
@@ -0,0 +1,13 @@
|
||||
get:
|
||||
operationId: GetMLHealthz
|
||||
summary: Check whether the ML process is responding.
|
||||
security: []
|
||||
tags:
|
||||
- health
|
||||
responses:
|
||||
"200":
|
||||
description: The ML process is responding.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: ../components/schemas.yml#/MLHealthResponse
|
||||
@@ -0,0 +1,19 @@
|
||||
get:
|
||||
operationId: GetMLReadyz
|
||||
summary: Check whether an inference runtime is available.
|
||||
security: []
|
||||
tags:
|
||||
- health
|
||||
responses:
|
||||
"200":
|
||||
description: An inference runtime is available.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: ../components/schemas.yml#/MLReadinessResponse
|
||||
"503":
|
||||
description: No inference runtime is available.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: ../components/schemas.yml#/MLReadinessResponse
|
||||
Generated
+45
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"name": "lincodex-api-contracts",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "lincodex-api-contracts",
|
||||
"devDependencies": {
|
||||
"@redocly/cli": "2.57.0",
|
||||
"prettier": "3.9.9"
|
||||
}
|
||||
},
|
||||
"node_modules/@redocly/cli": {
|
||||
"version": "2.57.0",
|
||||
"resolved": "https://registry.npmjs.org/@redocly/cli/-/cli-2.57.0.tgz",
|
||||
"integrity": "sha512-1d5fVyUaYlMNgCHUoyE2vUyxBhs/jmOHgsX/kFmfWzESw4f/G/OV/SU9E55rU7aUNmw9rHj1vXmL6yUdIn+KKQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"openapi": "bin/cli.js",
|
||||
"redocly": "bin/cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=22.12.0 || >=20.19.0 <21.0.0",
|
||||
"npm": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/prettier": {
|
||||
"version": "3.9.9",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.9.9.tgz",
|
||||
"integrity": "sha512-Z/CJHIkdujO/OtN7nXUii0Rf3VT5SRuhjBA82Xvu2XhBUgX3nhP67T0LHceBdQLex7OOFGTox+Q5Yg8Jk2Qivg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"prettier": "bin/prettier.cjs"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/prettier/prettier?sponsor=1"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"name": "lincodex-api-contracts",
|
||||
"private": true,
|
||||
"devDependencies": {
|
||||
"@redocly/cli": "2.57.0",
|
||||
"prettier": "3.9.9"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
extends:
|
||||
- recommended
|
||||
rules:
|
||||
info-license: off
|
||||
operation-4xx-response: off
|
||||
Vendored
+47
@@ -0,0 +1,47 @@
|
||||
openapi: 3.2.0
|
||||
info:
|
||||
title: OpenAPI 3.2 compatibility fixture
|
||||
version: 0.1.0
|
||||
servers:
|
||||
- url: /
|
||||
paths:
|
||||
/probe:
|
||||
get:
|
||||
operationId: GetProbe
|
||||
summary: Exercise OpenAPI 3.2 routing and input validation.
|
||||
security: []
|
||||
parameters:
|
||||
- name: state
|
||||
in: query
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
enum:
|
||||
- allowed
|
||||
responses:
|
||||
"200":
|
||||
description: The nullable value is generated with its validation type.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/NullablePayload"
|
||||
additionalOperations:
|
||||
PURGE:
|
||||
operationId: PurgeProbe
|
||||
summary: Exercise the OpenAPI 3.2 additionalOperations field.
|
||||
security: []
|
||||
responses:
|
||||
"204":
|
||||
description: The compatibility fixture operation completed.
|
||||
components:
|
||||
schemas:
|
||||
NullablePayload:
|
||||
type: object
|
||||
additionalProperties: false
|
||||
required:
|
||||
- value
|
||||
properties:
|
||||
value:
|
||||
type:
|
||||
- string
|
||||
- "null"
|
||||
Reference in new issue
Block a user