// Copyright 2026 Google LLC
//
// Licensed 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.

syntax = "proto3";

package google.cloud.ces.v1;

import "google/api/field_behavior.proto";
import "google/protobuf/struct.proto";

option go_package = "cloud.google.com/go/ces/apiv1/cespb;cespb";
option java_multiple_files = true;
option java_outer_classname = "SchemaProto";
option java_package = "com.google.cloud.ces.v1";

// Represents a select subset of an OpenAPI 3.0 schema object.
message Schema {
  // OpenAPI data types.
  enum Type {
    // Type unspecified.
    TYPE_UNSPECIFIED = 0;

    // String type.
    STRING = 1;

    // Integer type.
    INTEGER = 2;

    // Number type.
    NUMBER = 3;

    // Boolean type.
    BOOLEAN = 4;

    // Object type.
    OBJECT = 5;

    // Array type.
    ARRAY = 6;
  }

  // Required. The type of the data.
  Type type = 1 [(google.api.field_behavior) = REQUIRED];

  // Optional. Properties of Type.OBJECT.
  map<string, Schema> properties = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Required properties of Type.OBJECT.
  repeated string required = 3 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The description of the data.
  string description = 4 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Schema of the elements of Type.ARRAY.
  Schema items = 5 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Indicates if the value may be null.
  bool nullable = 6 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Indicate the items in the array must be unique. Only applies to
  // TYPE.ARRAY.
  bool unique_items = 7 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Schemas of initial elements of Type.ARRAY.
  repeated Schema prefix_items = 8 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Can either be a boolean or an object, controls the presence of
  // additional properties.
  Schema additional_properties = 9 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The value should be validated against any (one or more) of the
  // subschemas in the list.
  repeated Schema any_of = 10 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Possible values of the element of primitive type with enum
  // format. Examples:
  // 1. We can define direction as :
  // {type:STRING, format:enum, enum:["EAST", NORTH", "SOUTH", "WEST"]}
  // 2. We can define apartment number as :
  // {type:INTEGER, format:enum, enum:["101", "201", "301"]}
  repeated string enum = 11 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Default value of the data.
  google.protobuf.Value default = 12 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Allows indirect references between schema nodes. The value should
  // be a valid reference to a child of the root `defs`.
  //
  // For example, the following schema defines a reference to a schema node
  // named "Pet":
  //
  // ```
  // type: object
  // properties:
  //   pet:
  //     ref: #/defs/Pet
  // defs:
  //   Pet:
  //     type: object
  //     properties:
  //       name:
  //         type: string
  // ```
  //
  // The value of the "pet" property is a reference to the schema node
  // named "Pet".
  // See details in
  // https://json-schema.org/understanding-json-schema/structuring.
  string ref = 13 [(google.api.field_behavior) = OPTIONAL];

  // Optional. A map of definitions for use by `ref`. Only allowed at the root
  // of the schema.
  map<string, Schema> defs = 14 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The title of the schema.
  string title = 15 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Minimum number of the elements for Type.ARRAY.
  int64 min_items = 16 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Maximum number of the elements for Type.ARRAY.
  int64 max_items = 17 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Minimum value for Type.INTEGER and Type.NUMBER.
  optional double minimum = 18 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Maximum value for Type.INTEGER and Type.NUMBER.
  optional double maximum = 19 [(google.api.field_behavior) = OPTIONAL];
}
