Documentation
¶
Index ¶
- func GetFormattedExamples(examples ast.Examples) []string
- func GetSerializedDefault(field *ast.FieldDef) *string
- func NewDocsData(ast *ast.AST) ([]*string, error)
- func SerializeAbout(docs *Docs, ast *ast.AST) error
- func SerializeOperation(docs *Docs, operation *ast.Operation, tag string) (string, error)
- func SerializeSchema(docs *Docs, typeDef *ast.TypeDef, isNullable bool, defaultValue *string) (*string, error)
- func SerializeSecurity(docs *Docs, security *ast.TypeDef, isGlobal bool) (*string, error)
- func SerializeTag(docs *Docs, tag string, description *string, operationIds []string) error
- type AboutChunk
- type AboutData
- type AnnotatedOperation
- type ArrayValue
- type ChunkValue
- type Contact
- type Docs
- type EnumValue
- type License
- type ObjectValue
- type OperationChunk
- type OperationData
- type Parameter
- type PrimitiveValue
- type RequestBody
- type Response
- type SchemaChunk
- type SchemaData
- type SchemaValue
- type Security
- type SecurityChunk
- type SecurityData
- type SecurityEntryData
- type Server
- type TagChunk
- type TagData
- type TopLevelExample
- type UnionValue
- type ValueType
- type XCodeSample
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetFormattedExamples ¶
func GetSerializedDefault ¶
func NewDocsData ¶
Creates docs data from the given AST. This function returns chunks in a serialized format that can be written to a JSONL file, sent across an IPC connection, sent over a network connection, etc.
func SerializeOperation ¶
func SerializeSchema ¶
func SerializeSecurity ¶
Types ¶
type AboutChunk ¶
type AboutData ¶
type AboutData struct {
Title string `json:"title"`
Summary string `json:"summary"`
Description string `json:"description"`
TermsOfService string `json:"termsOfService"`
Version string `json:"version"`
Contact *Contact `json:"contact"`
License *License `json:"license"`
Servers []Server `json:"servers"`
}
type AnnotatedOperation ¶
type ArrayValue ¶
type ArrayValue struct {
Type ValueType `json:"type"`
Description *string `json:"description"`
Examples []string `json:"examples"`
Items SchemaValue `json:"items"`
Default *string `json:"defaultValue"`
MinItems *int64 `json:"minItems"`
MaxItems *int64 `json:"maxItems"`
}
func NewArrayValue ¶
func NewArrayValue(arrayType ValueType, typeDef *ast.TypeDef, defaultValue *string) *ArrayValue
func (*ArrayValue) GetValueType ¶
func (a *ArrayValue) GetValueType() ValueType
func (*ArrayValue) ParseArrayTypeDef ¶
func (a *ArrayValue) ParseArrayTypeDef(docs *Docs, typeDef *ast.TypeDef) error
type ChunkValue ¶
func NewChunkValue ¶
func NewChunkValue(chunkId string) *ChunkValue
func (*ChunkValue) GetValueType ¶
func (c *ChunkValue) GetValueType() ValueType
type Contact ¶
type Contact struct {
Name string `json:"name"`
URL string `json:"url"`
Email string `json:"email"`
}
Note: this is a trimmed down version of the Contact/License types found in the high-level model, since we don't want the low model or extensions
type Docs ¶
type Docs struct {
// contains filtered or unexported fields
}
func (*Docs) GenerateID ¶
func (*Docs) GetCachedIdFromSlug ¶
func (*Docs) RegisterSlug ¶
TODO: This is something of a quick-n-dirty way to record and check if we've processed an chunk before, to prevent infinite recursion. It's not great though since not all chunks have slugs. We'll need to fix a few issues to make this more robust though, so I'm punting for the time being.
func (*Docs) SaveSerializedChunk ¶
Save a serialized chunk so that we can later save it to disk. One day, we can also use this to immediately send a chunk to the renderer over IPC/etc.
type EnumValue ¶
type EnumValue struct {
Type ValueType `json:"type"`
Description *string `json:"description"`
Examples []string `json:"examples"`
Values []string `json:"values"`
Default *string `json:"defaultValue"`
}
func NewEnumValue ¶
func (*EnumValue) GetValueType ¶
type ObjectValue ¶
type ObjectValue struct {
Type ValueType `json:"type"`
Description *string `json:"description"`
Examples []string `json:"examples"`
Properties map[string]SchemaValue `json:"properties"`
Required []string `json:"required"`
Deprecated bool `json:"deprecated"`
Name string `json:"name"`
Default *string `json:"defaultValue"`
}
func NewObjectValue ¶
func NewObjectValue(name string, typeDef *ast.TypeDef, defaultValue *string) *ObjectValue
func (*ObjectValue) GetValueType ¶
func (o *ObjectValue) GetValueType() ValueType
func (*ObjectValue) ParseObjectTypeDef ¶
func (o *ObjectValue) ParseObjectTypeDef(docs *Docs, typeDef *ast.TypeDef) error
type OperationChunk ¶
type OperationChunk struct {
ID string `json:"id"`
Slug string `json:"slug"`
ChunkData OperationData `json:"chunkData"`
ChunkType string `json:"chunkType"`
}
type OperationData ¶
type OperationData struct {
OperationID string `json:"operationId"`
Path string `json:"path"`
Method string `json:"method"`
Summary string `json:"summary"`
Description string `json:"description"`
Parameters []Parameter `json:"parameters"`
RequestBody *RequestBody `json:"requestBody"`
Responses map[string][]Response `json:"responses"`
Tag string `json:"tag"`
Security *Security `json:"security"`
Deprecated bool `json:"deprecated"`
CodeSamples map[string]string `json:"codeSamples"`
}
type PrimitiveValue ¶
type PrimitiveValue struct {
Type ValueType `json:"type"`
Description *string `json:"description"`
Examples []string `json:"examples"`
Default *string `json:"defaultValue"`
MinLength *int64 `json:"minLength"`
MaxLength *int64 `json:"maxLength"`
Minimum *float64 `json:"minimum"`
Maximum *float64 `json:"maximum"`
Pattern *string `json:"pattern"`
}
func NewPrimitiveValue ¶
func NewPrimitiveValue(primitiveType ValueType, typeDef *ast.TypeDef, defaultValue *string) *PrimitiveValue
func (*PrimitiveValue) GetValueType ¶
func (p *PrimitiveValue) GetValueType() ValueType
type RequestBody ¶
type RequestBody struct {
Description string `json:"description"`
Required bool `json:"required"`
ContentChunkID string `json:"contentChunkId"`
Examples []TopLevelExample `json:"examples"`
}
type Response ¶
type Response struct {
Description string `json:"description"`
ContentType string `json:"contentType"`
ContentChunkID string `json:"contentChunkId"`
Examples []TopLevelExample `json:"examples"`
}
type SchemaChunk ¶
type SchemaChunk struct {
ID string `json:"id"`
Slug string `json:"slug"`
ChunkData SchemaData `json:"chunkData"`
ChunkType string `json:"chunkType"`
}
type SchemaData ¶
type SchemaData struct {
Name string `json:"name"`
Value SchemaValue `json:"value"`
}
type SecurityChunk ¶
type SecurityChunk struct {
ID string `json:"id"`
Slug string `json:"slug"`
ChunkData SecurityData `json:"chunkData"`
ChunkType string `json:"chunkType"`
}
type SecurityData ¶
type SecurityData struct {
ID string `json:"id"`
Entries []SecurityEntryData `json:"entries"`
}
type SecurityEntryData ¶
type TopLevelExample ¶
type UnionValue ¶
type UnionValue struct {
Type ValueType `json:"type"`
Description *string `json:"description"`
Examples []string `json:"examples"`
Values []SchemaValue `json:"values"`
Default *string `json:"defaultValue"`
}
func NewNullableValue ¶
func NewNullableValue(valueType SchemaValue, typeDef *ast.TypeDef) *UnionValue
If a given type is nullable, we convert the type to a union type containing the given type and a null value
func NewUnionValue ¶
func NewUnionValue(typeDef *ast.TypeDef, defaultValue *string) *UnionValue
func (*UnionValue) GetValueType ¶
func (u *UnionValue) GetValueType() ValueType
func (*UnionValue) ParseUnionTypeDef ¶
func (u *UnionValue) ParseUnionTypeDef(docs *Docs, typeDef *ast.TypeDef) error
type ValueType ¶
type ValueType string
const ( StringType ValueType = "string" DateStringType ValueType = "date" DateTimeStringType ValueType = "date-time" BooleanType ValueType = "boolean" NumberType ValueType = "number" IntegerType ValueType = "integer" Int32Type ValueType = "int32" Float32Type ValueType = "float32" DecimalType ValueType = "decimal" BigIntType ValueType = "bigint" ObjectType ValueType = "object" ArrayType ValueType = "array" SetType ValueType = "set" MapType ValueType = "map" EventStreamType ValueType = "event-stream" JsonLType ValueType = "jsonl" UnionType ValueType = "union" EnumType ValueType = "enum" // We set null as a separate type and turn any type that is nullable into a // union of that type and a null type. This way, null shows up like any other // type in the UI NullType ValueType = "null" // DataTypeBytes, DataTypeRequestStream, DataTypeResponseStream are all // combined into this binary type here BinaryType ValueType = "binary" AnyType ValueType = "any" // This type is used to create a layer of indirection such that objects and // arrays are never nested directly. This way we can serialize circular // references easily, and also more give the UI more flexibility when deciding // how to display deeply nested data. This type is the primary difference with // TypeDefs, since TypeDefs have no such concept. ChunkType ValueType = "chunk" )
Most of these match the types in TypeDef 1:1, but there are a few differences