google / gnostic

A compiler for APIs described by the OpenAPI Specification with plugins for code generation and other API support tasks.
Apache License 2.0
2.04k stars 241 forks source link

getting issue when generating the OAS V3 from protofile #246

Open NehaSachan opened 3 years ago

NehaSachan commented 3 years ago

Command: tried this => protoc -I proto/ sample.proto -I. --openapi_out=. tried this => protoc sample.proto -I. --openapi_out=.

Version: gnostic@v0.5.5

Error: panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x48 pc=0x14c8759]

goroutine 1 [running]: github.com/googleapis/gnostic/apps/protoc-gen-openapi/generator.(OpenAPIv3Generator).addPathsToDocumentV3(0xc0002a0e60, 0xc000143680, 0xc0002f1900) github.com/googleapis/gnostic@v0.5.5/apps/protoc-gen-openapi/generator/openapi-v3.go:136 +0x1d9 github.com/googleapis/gnostic/apps/protoc-gen-openapi/generator.(OpenAPIv3Generator).buildDocumentV3(0xc0002a0e60, 0x1) github.com/googleapis/gnostic@v0.5.5/apps/protoc-gen-openapi/generator/openapi-v3.go:83 +0x178 github.com/googleapis/gnostic/apps/protoc-gen-openapi/generator.(*OpenAPIv3Generator).Run(0xc0002a0e60, 0xc0002a0e60, 0x0) github.com/googleapis/gnostic@v0.5.5/apps/protoc-gen-openapi/generator/openapi-v3.go:57 +0x2f main.main.func1(0xc000268e60, 0x0, 0xc0001780e0) github.com/googleapis/gnostic@v0.5.5/apps/protoc-gen-openapi/main.go:25 +0x39 google.golang.org/protobuf/compiler/protogen.run(0x0, 0x0, 0x15e5d80, 0x1a95900, 0x0) google.golang.org/protobuf@v1.26.0/compiler/protogen/protogen.go:74 +0x1e2 google.golang.org/protobuf/compiler/protogen.Options.Run(0x0, 0x0, 0x15e5d80) google.golang.org/protobuf@v1.26.0/compiler/protogen/protogen.go:52 +0x5a main.main() github.com/googleapis/gnostic@v0.5.5/apps/protoc-gen-openapi/main.go:24 +0x35 --openapi_out: protoc-gen-openapi: Plugin failed with status code 2.

Please resolve this issue.

NehaSachan commented 3 years ago

@timburks @guptasu @gizzon @glickbot Please take a look and let me know how to fix this.

timburks commented 3 years ago

Hi, could you provide the sample.proto that you used? (apologies if it's here and I missed it)

timburks commented 3 years ago

You might also find it helpful to try the master branch; https://github.com/google/gnostic/pull/249 may have fixed this problem.

NehaSachan commented 3 years ago

@timburks

Yes thanks its fixed.

But now running into another issuer ..... How to add Summary, Description with Request Body And How to add HttpStatusCode like 200, 404, 500 And multiple others With RESPONSE

to show them in oas spec file when we pass proto file.

TRIED SAME SAMPLE EXAMPLE WHICH IS mentioned in your repository

protoc -I proto/ sample.proto -I. --openapi_out=.