@autorest/go
Version:
AutoRest Go Generator
316 lines • 11.7 kB
TypeScript
/** Docs contains the values used in doc comment generation. */
export interface Docs {
/** the high level summary */
summary?: string;
/** detailed description */
description?: string;
}
/** defines types that go across the wire */
export type WireType = Any | Constant | EncodedBytes | Interface | Literal | Map | Model | PolymorphicModel | QualifiedType | RawJSON | Scalar | Slice | String | Time;
/** the Go any type */
export interface Any {
kind: 'any';
}
/** a const type definition */
export interface Constant {
kind: 'constant';
/** the const type name */
name: string;
/** any docs for the const type */
docs: Docs;
/** the underlying type of the const */
type: ConstantType;
/** the possible values for this const */
values: Array<ConstantValue>;
/** the name of the func that returns the set of values */
valuesFuncName: string;
}
/** the underlying type of a const */
export type ConstantType = 'bool' | 'float32' | 'float64' | 'int32' | 'int64' | 'string';
/** a const value definition */
export interface ConstantValue {
kind: 'constantValue';
/** the const value name */
name: string;
/** any docs for the const value */
docs: Docs;
/** the const to which this value belongs */
type: Constant;
/** the value for this const */
value: ConstantValueType;
}
/** the underlying type of a const value */
export type ConstantValueType = boolean | number | string;
/** a byte slice that's base64 encoded */
export interface EncodedBytes {
kind: 'encodedBytes';
/** indicates what kind of base64-encoding to use */
encoding: BytesEncoding;
}
/** the types of base64 encoding */
export type BytesEncoding = 'Std' | 'URL';
/** a Go interface type used for discriminated types */
export interface Interface {
kind: 'interface';
/** the name of the interface (e.g. FishClassification) */
name: string;
/** any docs for the interface */
docs: Docs;
/** contains possible concrete type instances (e.g. Flounder, Carp) */
possibleTypes: Array<PolymorphicModel>;
/** contains the name of the discriminator field in the JSON (e.g. "fishtype") */
discriminatorField: string;
/** does this polymorphic type have a parent (e.g. SalmonClassification has parent FishClassification) */
parent?: Interface;
/** this is the "root" type in the list of polymorphic types (e.g. Fish for FishClassification) */
rootType: PolymorphicModel;
}
/** a literal value (e.g. "foo", 123, true) */
export interface Literal {
kind: 'literal';
/** the literal's underlying type */
type: LiteralType;
/** the value for this literal */
literal: any;
}
/** the possible types of literals */
export type LiteralType = Constant | EncodedBytes | Scalar | String | Time;
/** a Go map type. note that the key is always a string */
export interface Map {
kind: 'map';
/** the type of values in the map */
valueType: MapValueType;
/** indicates if the map's value type is pointer-to-type or not */
valueTypeByValue: boolean;
}
/** the set of map value types */
export type MapValueType = WireType;
/** a field within a model */
export interface ModelField extends StructField {
/** the name of the field as it's sent/received over the wire */
serializedName: string;
/** metadata for this field */
annotations: ModelFieldAnnotations;
/** the value to send over the wire if one isn't specified */
defaultValue?: Literal;
/** any XML metadata */
xml?: XMLInfo;
}
/** additional settings for a model type */
export interface ModelAnnotations {
/** when true, serde methods will not be generated */
omitSerDeMethods: boolean;
/** indicates the model should be converted into multipart/form data */
multipartFormData: boolean;
}
/** additional settings for a model field */
export interface ModelFieldAnnotations {
/** the field is required on input and will always be populated on output */
required: boolean;
/** the field is read-only and will be populated on output. any set value on input will be ignored */
readOnly: boolean;
/** field is JSON additional properties */
isAdditionalProperties: boolean;
/** field is the discriminator for a discriminated type */
isDiscriminator: boolean;
}
/** a struct that participates in serialization over the wire */
export interface Model extends ModelBase {
kind: 'model';
}
/** a model that's a discriminated type */
export interface PolymorphicModel extends ModelBase {
kind: 'polymorphicModel';
/** the polymorphic interface this type implements */
interface: Interface;
/**
* the value in the JSON that indicates what type was sent over the wire (e.g. goblin, salmon, shark)
* note that for "root" types (Fish), there is no discriminatorValue. however, "sub-root" types (e.g. Salmon)
* will have this populated.
*/
discriminatorValue?: Literal;
}
/** a type from some package, e.g. the Go standard library (excluding time.Time) */
export interface QualifiedType {
kind: 'qualifiedType';
/** the type name minus any package qualifier (e.g. URL) */
exportName: string;
/** the full name of the package to import (e.g. "net/url") */
packageName: string;
}
/** a byte slice containing raw JSON */
export interface RawJSON {
kind: 'rawJSON';
}
/** a Go scalar type */
export interface Scalar {
kind: 'scalar';
/** the type of scalar */
type: ScalarType;
/** indicates the value is sent/received as a string */
encodeAsString: boolean;
}
/** the supported Go scalar types */
export type ScalarType = 'bool' | 'byte' | 'float32' | 'float64' | 'int8' | 'int16' | 'int32' | 'int64' | 'rune' | 'uint8' | 'uint16' | 'uint32' | 'uint64';
/** a Go slice */
export interface Slice {
kind: 'slice';
/** the element type for this slice */
elementType: SliceElementType;
/** indicates if the slice's element type is pointer-to-type or not */
elementTypeByValue: boolean;
}
/** the set of slice element types */
export type SliceElementType = WireType;
/** a Go string */
export interface String {
kind: 'string';
}
/** a vanilla struct definition (pretty much exclusively used for parameter groups/options bag types) */
export interface Struct {
/** the name of the struct */
name: string;
/** and docs for this struct */
docs: Docs;
/** the fields in this struct. can be empty */
fields: Array<StructField>;
}
/** a field definition within a struct */
export interface StructField {
/** the name of the field */
name: string;
/** and docs for this field */
docs: Docs;
/** the field's underlying type */
type: WireType;
/** indicates if the field is pointer-to-type or not */
byValue: boolean;
}
/** a time.Time type from the standard library with a format specifier */
export interface Time {
kind: 'time';
/** the serde format used */
format: TimeFormat;
/** indicates if the time is always in UTC */
utc: boolean;
}
/** the set of time serde formats */
export type TimeFormat = 'dateType' | 'dateTimeRFC1123' | 'dateTimeRFC3339' | 'timeRFC3339' | 'timeUnix';
/** bit flags indicating how a model/polymorphic type is used */
export declare enum UsageFlags {
/** the type is unreferenced */
None = 0,
/** the type is received over the wire */
Input = 1,
/** the type is sent over the wire */
Output = 2
}
/** metadata used for XML serde */
export interface XMLInfo {
/** element name to use instead of the default name */
name?: string;
/** name propagated to the generated wrapper type */
wrapper?: string;
/** slices only. this is the name of the wrapped type */
wraps?: string;
/** value is an XML attribute */
attribute: boolean;
/** value is raw text */
text: boolean;
}
/**
* returns the Go type declaration for the specified LiteralType
*
* @param literal the type for which to emit the declaration
* @returns the Go type declaration
*/
export declare function getLiteralTypeDeclaration(literal: LiteralType): string;
/**
* returns the Go type declaration for the specified type.
* any value in pkgName is prefixed to the underlying type name.
*
* @param type the type for which to emit the declaration
* @param pkgName optional package name prefix for the type
* @returns the Go type declaration
*/
export declare function getTypeDeclaration(type: WireType, pkgName?: string): string;
/** narrows type to a LiteralType within the conditional block */
export declare function isLiteralValueType(type: WireType): type is LiteralType;
export declare class StructField implements StructField {
constructor(name: string, type: WireType, byValue: boolean);
}
export declare class Struct implements Struct {
constructor(name: string);
}
interface ModelBase extends Struct {
/** the fields in this model. can be empty */
fields: Array<ModelField>;
/** any annotations for this model */
annotations: ModelAnnotations;
/** usage flags for this model */
usage: UsageFlags;
/** any XML metadata */
xml?: XMLInfo;
}
declare class ModelBase extends Struct implements ModelBase {
constructor(name: string, annotations: ModelAnnotations, usage: UsageFlags);
}
export declare class Any implements Any {
constructor();
}
export declare class Constant implements Constant {
constructor(name: string, type: ConstantType, valuesFuncName: string);
}
export declare class ConstantValue implements ConstantValue {
constructor(name: string, type: Constant, value: ConstantValueType);
}
export declare class EncodedBytes implements EncodedBytes {
constructor(encoding: BytesEncoding);
}
export declare class Interface implements Interface {
constructor(name: string, discriminatorField: string);
}
export declare class Literal implements Literal {
constructor(type: LiteralType, literal: any);
}
export declare class Map implements Map {
constructor(valueType: MapValueType, valueTypeByValue: boolean);
}
export declare class ModelAnnotations implements ModelAnnotations {
constructor(omitSerDe: boolean, multipartForm: boolean);
}
export declare class ModelField extends StructField implements ModelField {
constructor(name: string, type: WireType, byValue: boolean, serializedName: string, annotations: ModelFieldAnnotations);
}
export declare class ModelFieldAnnotations implements ModelFieldAnnotations {
constructor(required: boolean, readOnly: boolean, isAddlProps: boolean, isDiscriminator: boolean);
}
export declare class Model extends ModelBase implements Model {
constructor(name: string, annotations: ModelAnnotations, usage: UsageFlags);
}
export declare class PolymorphicModel extends ModelBase implements PolymorphicModel {
constructor(name: string, iface: Interface, annotations: ModelAnnotations, usage: UsageFlags);
}
export declare class QualifiedType implements QualifiedType {
constructor(exportName: string, packageName: string);
}
export declare class RawJSON implements RawJSON {
constructor();
}
export declare class Scalar implements Scalar {
constructor(type: ScalarType, encodeAsString: boolean);
}
export declare class Slice implements Slice {
constructor(elementType: SliceElementType, elementTypeByValue: boolean);
}
export declare class String implements String {
constructor();
}
export declare class Time implements Time {
constructor(format: TimeFormat, utc: boolean);
}
export declare class XMLInfo implements XMLInfo {
constructor();
}
export {};
//# sourceMappingURL=type.d.ts.map