nytimes / openapi2proto

A tool for generating Protobuf v3 schemas and gRPC service definitions from OpenAPI specifications

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Generating Empty Request + Response

mjallday opened this issue · comments

openapi: '3.0.0'
info:
  title: Example API

paths:
  /records:
    post:
      operationId: createRecords
      tags:
        - records
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                data:
                  type: array
                  items:
                    $ref: '#/components/schemas/RecordCreateRequest'
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/Record'

components:

  schemas:
    Record:
      type: "object"
      properties:
        id:
          type: "string"
          example: RCvafeqcnYSvHLxtqAhur7MX

    RecordCreateRequest:
      type: "object"
      properties:
        value:
          type: "string"
          example: fooo

Gives me

syntax = "proto3";

package exampleapi;

import "google/protobuf/empty.proto";

service ExampleAPIService {
    rpc CreateRecords(google.protobuf.Empty) returns (google.protobuf.Empty) {}
}

Any idea why it's generating the input and return types as google.protobuf.Empty?

Sorry, this tool is only set up for the Open API v2 specification. The differences in schemas means this tool is unable to read the requestBody field.

I could've sworn we had something in the README calling this out, but I guess I need to make an issue. 😓

Thanks for the info JP. I was crawling the issues and thought I saw someone using v3.