Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: check for nil example #37

Merged
merged 1 commit into from
Oct 8, 2024
Merged

fix: check for nil example #37

merged 1 commit into from
Oct 8, 2024

Conversation

Freebien
Copy link
Contributor

@Freebien Freebien commented Oct 8, 2024

Hi I had a panic with a nil pointer dereference when trying to set a Header without an example.

Here is a fix that checks the existance of the example before getting the raw info. (maybe the issue is more on the gnostic side, but since it's some generated code, I don't know how to work with it).

Here is an example that does the panic.

syntax = "proto3";
package auth.login;

option go_package = "gen/auth";

import "gnostic/openapi/v3/annotations.proto";

service AuthService {
    rpc Login(LoginRequest) returns (LoginResponse) {
        option (gnostic.openapi.v3.operation) = {
            responses: {
                response_or_reference: [{
                    name: "200",
                    value: {
                        response: {
                            description: "Login success"
                            headers: {
                                additional_properties: [{
                                    name: "Set-Cookie"
                                    value: {
                                        header: {
                                            description: "header description"
                                            /* if this is commented, it panics
                                            example: {
                                                yaml: "header example"
                                            }
                                            */
                                            schema: {
                                                schema: {
                                                    type: "string"
                                                    example: {
                                                        yaml: "schema example"
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }]
                            }
                        }
                    }
                }]
            },
            security: [
                {
                    additional_properties: []
                }
            ]
        };
    };
}

message LoginRequest {
    string username = 1;
    string password = 2;
}

message LoginResponse {
    bool success = 1;
}

@sudorandom sudorandom merged commit 5b29f10 into sudorandom:main Oct 8, 2024
2 checks passed
sudorandom pushed a commit that referenced this pull request Oct 24, 2024
sudorandom added a commit that referenced this pull request Oct 24, 2024
* fix: check for nil example (#37)

* feat: add protobuf annotations to field descriptions

Adjust numeric types -> openAPI to be more accurate

---------

Co-authored-by: Fabien Kleinbourg <freebien@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants