converter

package
v0.0.0-...-59aa0c4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 6, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewGeneratorPlan

func NewGeneratorPlan() *generatorPlan

func NewProtoTypeInfoForEnum

func NewProtoTypeInfoForEnum(targetFileName string, protoPackage string, parent *protoTypeInfo,
	protoEnum *descriptor.EnumDescriptorProto) *protoTypeInfo

func NewProtoTypeInfoForMsg

func NewProtoTypeInfoForMsg(targetFileName string, protoPackage string, parent *protoTypeInfo,
	protoMsg *descriptor.DescriptorProto) *protoTypeInfo

Types

type Components

type Components struct {
	VendorExtensible `json:"-"`

	Schemas         Schemas         `json:"schemas,omitempty"`
	Responses       json.RawMessage `json:"responses,omitempty"`
	Parameters      json.RawMessage `json:"parameters,omitempty"`
	Examples        json.RawMessage `json:"examples,omitempty"`
	RequestBodies   json.RawMessage `json:"requestBodies,omitempty"`
	Headers         json.RawMessage `json:"headers,omitempty"`
	SecuritySchemes json.RawMessage `json:"securitySchemes,omitempty"`
	Links           json.RawMessage `json:"links,omitempty"`
	Callbacks       json.RawMessage `json:"callbacks,omitempty"`
}

Components holds a set of reusable objects for different aspects of the OAS. All objects defined within the components object will have no effect on the API unless they are explicitly referenced from properties outside the components object.

type Converter

type Converter struct {
	// Allow NULL values for all properties. By default, JSON Schemas will reject NULL values.
	AllowNullValues bool
	// Allow additional properties. JSON Schemas will allow extra parameters, that are not specified in the schema.
	AllowAdditionalProperties bool
	// If the parameter is not set (default) the JSON Schema will allow both string and integers for 64 bit integers.
	// If it is set only integers are allowed.
	// The canonical JSON encoding of Proto3 converts int64, fixed64, uint6 to JSON strings.
	// When decoding JSON to ProtoBuf both numbers and strings are accepted.
	DisallowBigIntsAsStrings bool
	// Allow both enum names and integer values.
	AllowNumericEnumValues bool
	// Path to an OpenAPI file that will be merged with the generated schemas.
	OpenApiFile string

	// If the parameter is set the field names from the ProtoBuf definition are used in the JSON Schema.
	// If the parameter is not set message field names are mapped to lowerCamelCase and become JSON object keys.
	UseProtoFieldNames bool
	// contains filtered or unexported fields
}

Converter is everything you need to convert protos to JSON Schemas:

func New

func New(logger *logrus.Logger) *Converter

New returns a configured *Converter:

func (*Converter) ConvertFrom

func (c *Converter) ConvertFrom(rd io.Reader) (*plugin.CodeGeneratorResponse, error)

ConvertFrom tells the convert to work on the given input:

type OpenAPI

type OpenAPI struct {
	VendorExtensible `json:"-"`

	Components   Components      `json:"components,omitempty"`
	ExternalDocs json.RawMessage `json:"externalDocs,omitempty"`
	Info         json.RawMessage `json:"info,omitempty"`
	OpenAPI      string          `json:"openapi"`
	Paths        json.RawMessage `json:"paths,omitempty"`
	Security     json.RawMessage `json:"security,omitempty"`
	Servers      json.RawMessage `json:"servers,omitempty"`
	Tags         json.RawMessage `json:"tags,omitempty"`
}

OpenAPI is the root document object of the OpenAPI document

type Schemas

type Schemas map[string]*jsonschema.Type

type VendorExtensible

type VendorExtensible map[string]json.RawMessage

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL