gnostic icon indicating copy to clipboard operation
gnostic copied to clipboard

Exclude proto message fields from OpenAPI spec

Open grizzlybearer opened this issue 4 years ago • 2 comments

Is it possible to exclude certain fields defined in a protobuf and its corresponding graph from the OpenAPI spec generated by https://github.com/google/gnostic/tree/master/apps/protoc-gen-openapi ?

Say the proto is

Message SomeProto {
     string field_1 = 1;
     AnotherProto field_2 = 2; // exclude this
}
// this proto should not be included in the OpenAPI spec
Message AnotherProto {
   SomeMoreDepProto field = 1;
    ...
}

Currently, the OpenAPI spec defines all of these protos under the components->schemas

components:
    schemas:
        SomeProto:
            properties:
                field_1:
                    type: string
                    description: ''
                field_2:
                    ref: $ref: '#/components/schemas/AnotherProto'
        AnotherProto:
            properties:
                field_1:
                    ref: $ref: '#/components/schemas/SomeMoreDepProto'

AnotherProto and SomeMoreDepProto are internal protos that I cannot expose.

I need the OpenAPI spec to thus be

components:
    schemas:
        SomeProto:
            properties:
                field_1:
                    type: string
                    description: ''

grizzlybearer avatar Nov 02 '21 20:11 grizzlybearer

Tagging active members to seek attention - @timburks @ppaanngggg

grizzlybearer avatar Feb 24 '23 13:02 grizzlybearer

as I know, it is impossible now

ppaanngggg avatar Feb 27 '23 04:02 ppaanngggg