File: surface.proto

package info (click to toggle)
golang-github-googleapis-gnostic 0.2.0-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,636 kB
  • sloc: makefile: 154; javascript: 106; sh: 57
file content (90 lines) | stat: -rw-r--r-- 3,362 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// Copyright 2017 Google Inc. All Rights Reserved.
//
// 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.

// Model an API surface for code generation.

syntax = "proto3";

package surface.v1;

enum FieldKind {
    SCALAR = 0;
    MAP = 1;
    ARRAY = 2;
    REFERENCE = 3;
}

enum TypeKind {
    STRUCT = 0; // implement with named fields
    OBJECT = 1; // implement with a map
}

enum Position {
    BODY = 0;
    HEADER = 1;
    FORMDATA = 2;
    QUERY = 3;
    PATH = 4;
}

// Field is a field in a definition and can be associated with
// a position in a request structure.
message Field {
    string name = 1; // the name as specified in the API description
    string type = 2; // the specified content type of the field
    FieldKind kind = 3; // what kind of thing is this field? scalar, reference, array, map of strings to the specified type
    string format = 4; // the specified format of the field
    Position position = 5; // "body", "header", "formdata", "query", or "path"

    string nativeType = 6; // the programming-language native type of the field
    string fieldName = 7; // the name to use for a data structure field
    string parameterName = 8; // the name to use for a function parameter

    bool serialize = 9; // true if this field should be serialized (to JSON, etc)
}

// Type typically corresponds to a definition, parameter, or response
// in an API and is represented by a type in generated code.
message Type {
    string name = 1; // the name to use for the type
    TypeKind kind = 2; // a meta-description of the type (struct, map, etc)
    string description = 3; // a comment describing the type
    string contentType = 4; // if the type is a map, this is its content type
    repeated Field fields = 5; // the fields of the type

    string typeName = 6; // language-specific type name
}

// Method is an operation of an API and typically has associated client and server code.
message Method {
    string operation = 1; // Operation ID
    string path = 2; // HTTP path
    string method = 3; // HTTP method name
    string description = 4; // description of method

    string name = 5; // Operation name, possibly generated from method and path
    string handlerName = 6; // name of the generated handler
    string processorName = 7; // name of the processing function in the service interface
    string clientName = 8; // name of client

    string parametersTypeName = 9; // parameters (input), with fields corresponding to input parameters
    string responsesTypeName = 10; // responses (output), with fields corresponding to possible response values
}

// Model represents an API for code generation.
message Model {
    string name = 1; // a free-form title for the API
    repeated Type types = 2; // the types used by the API
    repeated Method methods = 3; // the methods (functions) of the API
}