-
Notifications
You must be signed in to change notification settings - Fork 98
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
Support data model using allOf #89
Comments
Before diving into the details, I think there are a few things to note:
notes: the structure needs to be restricted to a hash (I believe it already is), and we basically just perform a merge first, and then apply the compilation on the result. If the merge finds conflicts, it should probably report an error. How should the merge work? probably the correct way to do it is to merge every level. Does that make sense in terms of cost and what not? |
I believe allOf is supported in openapi 2.0 : https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md |
hi thanks for pointing it out. I know it is supported. it's just an observation. it doesn't change the fact that 1. OP might be confused to begin with (including the error on the latter is one of the things that really but me while rewriting significant chunks of this software a few months back. namely, it does not tell you of errors in the document e.g. missing required fields, wrong element names, etc. so I thought I'd point that out |
Just tried it; the tool doesn't work w/ |
Well, I have my own itch to scratch, and have been working on https://github.com/lestrrat-go/openapi. I just tried writing up preliminary swagger: "2.0"
info:
version: "1.0.0"
title: "definition using allOf"
description: "blah"
definitions:
foo:
type: object
properties:
one:
type: string
two:
type: string
bar:
type: object
properties:
three:
type: integer
four:
type: integer
paths:
"/":
get:
operationId: "root"
description: "root"
parameters:
- name: param
in: body
schema:
allOf:
- $ref: "#/definitions/foo"
- $ref: "#/definitions/bar"
responses:
default:
description: success syntax = "proto3";
package myapp;
import "google/protobuf/empty.proto";
message Bar {
int32 four = 1;
int32 three = 2;
}
message Foo {
string one = 1;
string two = 2;
}
message RootRequest {
message Param {
int32 four = 1;
string one = 2;
int32 three = 3;
string two = 4;
}
Param param = 1;
}
service Myapp {
// root
rpc Root(RootRequest) returns (google.protobuf.Empty) {
}
} Right now I have to finish this up, so don't know when I'll be back to implementing it here, |
looks promising! it's a bit sad protocol buffer does not support inheritance. In this example we lose completly the fact the Param is made of Foo and Bar. message Param {
Foo foo = 1;
Bar bar = 2;
} WDYT? |
@darkantoine This will not translate well if we are using grpc-gateway. allOf means you will have a single object with all the properties specified, not 2 different objects. |
I made a pull request that handles a single allOf case, which is useful if you want a different description. For example, consider the following:
The
|
Exemple file
Give
message ExtendedPerson {} is not generated
Should return
The text was updated successfully, but these errors were encountered: