|
| 1 | +<!-- |
| 2 | +Licensed to the Apache Software Foundation (ASF) under one |
| 3 | +or more contributor license agreements. See the NOTICE file |
| 4 | +distributed with this work for additional information |
| 5 | +regarding copyright ownership. The ASF licenses this file |
| 6 | +to you under the Apache License, Version 2.0 (the |
| 7 | +"License"); you may not use this file except in compliance |
| 8 | +with the License. You may obtain a copy of the License at |
| 9 | +
|
| 10 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +
|
| 12 | +Unless required by applicable law or agreed to in writing, |
| 13 | +software distributed under the License is distributed on an |
| 14 | +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | +KIND, either express or implied. See the License for the |
| 16 | +specific language governing permissions and limitations |
| 17 | +under the License. |
| 18 | +--> |
| 19 | + |
| 20 | +# API specs |
| 21 | + |
| 22 | +Auto-generated OpenAPI specs for Apache Custos. |
| 23 | + |
| 24 | +## Layout |
| 25 | + |
| 26 | +One spec per code-ownership unit: |
| 27 | + |
| 28 | +| Spec | Path | Scope | |
| 29 | +|---|---|---| |
| 30 | +| Core | `api/core.openapi.yaml` | Core REST endpoints. | |
| 31 | +| Connector | `connectors/<NAME>/api/<name>.openapi.yaml` | A connector's endpoints under `/connectors/<name>/`. | |
| 32 | + |
| 33 | +Connector specs ship alongside the connector code; the core spec never |
| 34 | +declares connector endpoints. The reference connector today is AMIE at |
| 35 | +`connectors/ACCESS/AMIE-Processor/api/amie.openapi.yaml`. |
| 36 | + |
| 37 | +## Generating |
| 38 | + |
| 39 | +Specs are produced from [`swag`](https://github.com/swaggo/swag) |
| 40 | +annotations on each handler in the Go source. Regenerate after editing |
| 41 | +any annotation: |
| 42 | + |
| 43 | +``` |
| 44 | +make gen-api |
| 45 | +``` |
| 46 | + |
| 47 | +CI enforces freshness via `make verify-no-drift`: modifying a handler |
| 48 | +annotation without committing the regenerated spec fails the build. The |
| 49 | +`swag` version is pinned in `go.sum`; `go generate` invokes it through |
| 50 | +`go run`, so contributors do not need to install the binary separately. |
| 51 | + |
| 52 | +## Consuming |
| 53 | + |
| 54 | +Both files are standard OpenAPI documents and load into any |
| 55 | +OpenAPI-aware client, viewer, or codegen tool. |
0 commit comments