generator

package
v0.0.0-...-35d56b8 Latest Latest
Warning

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

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

Documentation

Overview

Copyright 2019 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.

descriptor_renderer generates a FileDescriptorSet from a gnostic output file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdjustSurfaceModel

func AdjustSurfaceModel(model *surface_v1.Model, inputDocumentType string)

AdjustSurfaceModel simplifies and prettifies the types and fields of the surface model in order to get a better looking output file. Related to: https://github.com/googleapis/gnostic-grpc/issues/11

func CleanName

func CleanName(name string) string

Removes characters which are not allowed for message names or field names inside .proto files.

func RunProtoGenerator

func RunProtoGenerator()

This is the main function for the code generation plugin.

Types

type GrpcChecker

type GrpcChecker struct {
	// contains filtered or unexported fields
}

func NewGrpcChecker

func NewGrpcChecker(document *openapiv3.Document) *GrpcChecker

Creates a new checker.

func (*GrpcChecker) Run

func (c *GrpcChecker) Run() []*plugins.Message

Runs the checker. It is a top-down approach.

type LineWriter

type LineWriter struct {
	bytes.Buffer
}

func NewLineWriter

func NewLineWriter() *LineWriter

func (*LineWriter) WriteLine

func (w *LineWriter) WriteLine(line string)

type ProtoLanguageModel

type ProtoLanguageModel struct{}

func NewProtoLanguageModel

func NewProtoLanguageModel() *ProtoLanguageModel

func (*ProtoLanguageModel) Prepare

func (language *ProtoLanguageModel) Prepare(model *surface_v1.Model, inputDocumentType string)

Prepare sets language-specific properties for all types and methods.

type Renderer

type Renderer struct {
	// The model holds the necessary information from the OpenAPI description.
	Model *surface.Model
	// The FileDescriptorSet that will be printed with protoreflect
	FdSet          *dpb.FileDescriptorSet
	SymbolicFdSets []*dpb.FileDescriptorSet
	Package        string // package name
}

Renderer generates a .proto file based on the information inside Model.

func NewRenderer

func NewRenderer(model *surface.Model) (renderer *Renderer)

NewRenderer creates a renderer.

func (*Renderer) Render

func (renderer *Renderer) Render(response *plugins.Response, fileName string) (err error)

Generate runs the renderer to generate the named files.

func (*Renderer) RenderDescriptor

func (renderer *Renderer) RenderDescriptor() (*plugins.File, error)

func (*Renderer) RenderProto

func (renderer *Renderer) RenderProto(fdSet *dpb.FileDescriptorSet, fileName string) (*plugins.File, error)

Jump to

Keyboard shortcuts

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