A11 (C++ runtime)
Native C++ implementation of the A11 streaming action runtime
Loading...
Searching...
No Matches
schema.h
Go to the documentation of this file.
1/*
2 * Copyright 2026 The A11 Authors
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef A11_FLOW_SCHEMA_H_
18#define A11_FLOW_SCHEMA_H_
19
20#include <string>
21#include <string_view>
22#include <vector>
23
24#include <nlohmann/json_fwd.hpp>
25
26#include "a11/flow/diagnostic.h"
27#include "a11/flow/plan.h"
28
29namespace a11::flow {
30
34nlohmann::json DtoToJsonSchema(const DtoPlan& dto, const Program& program);
35
39 std::vector<DtoPlan> dtos;
41 std::vector<Diagnostic> diagnostics;
42};
43
46SchemaImport JsonSchemaToDtos(const nlohmann::json& schema,
47 std::string_view name);
48
50std::string DtoToFlow(const DtoPlan& dto);
51
53inline constexpr std::string_view kSchemaFormat = "flow.schema/v1";
54
56inline constexpr std::string_view kFlowTypeKey = "x-a11-type";
57
59inline constexpr std::string_view kFlowOrderKey = "x-a11-order";
60
61} // namespace a11::flow
62
63#endif // A11_FLOW_SCHEMA_H_
std::string name
The declaration name and its colon.
Definition format.cc:50
bool dto
Definition format.cc:1378
Definition catalogue.cc:29
nlohmann::json DtoToJsonSchema(const DtoPlan &dto, const Program &program)
Converts a Flow shape to JSON Schema Draft 2020-12.
Definition schema.cc:818
SchemaImport JsonSchemaToDtos(const nlohmann::json &schema, std::string_view name)
Imports shapes from schema, using name when the root has no name.
Definition schema.cc:835
constexpr std::string_view kFlowOrderKey
Extension key preserving a shape's field declaration order.
Definition schema.h:59
constexpr std::string_view kSchemaFormat
The format field of the schema envelope.
Definition schema.h:53
std::string DtoToFlow(const DtoPlan &dto)
Renders one shape as formatted Flow source.
Definition schema.cc:890
constexpr std::string_view kFlowTypeKey
The extension key that says which Flow type a string really is.
Definition schema.h:56
One compiled struct: a shape a port may be typed with.
Definition plan.h:87
The shapes a JSON Schema describes, and what would not fit.
Definition schema.h:37
std::vector< DtoPlan > dtos
Root shape followed by referenced $defs entries.
Definition schema.h:39
std::vector< Diagnostic > diagnostics
Unsupported schema features reported without Flow source ranges.
Definition schema.h:41