-
Notifications
You must be signed in to change notification settings - Fork 38
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(flatten): allows the use of pointers to schemas in x-... extensions #89
Conversation
f7563d0
to
45eca10
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #89 +/- ##
==========================================
+ Coverage 83.37% 92.68% +9.30%
==========================================
Files 14 7 -7
Lines 2490 1899 -591
==========================================
- Hits 2076 1760 -316
+ Misses 364 101 -263
+ Partials 50 38 -12
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Here is the spec from go-swagger/go-swagger#1898 used for testing this feature. {
"swagger": "2.0",
"info": {
"title": "example.proto",
"version": "version not set"
},
"schemes": [
"http",
"https"
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"paths": {
"/example/v2/GetEvents": {
"get": {
"operationId": "GetEvents",
"responses": {
"200": {
"description": "A successful response.(streaming responses)",
"schema": {
"$ref": "#/x-stream-definitions/v2EventMsg"
}
}
},
"parameters": [
{
"name": "afterEventID",
"description": ".",
"in": "query",
"required": false,
"type": "string"
}
],
"tags": [
"Matchmaking"
]
}
}
},
"definitions": {
"protobufAny": {
"type": "object",
"properties": {
"type_url": {
"type": "string"
},
"value": {
"type": "string",
"format": "byte"
}
}
},
"runtimeStreamError": {
"type": "object",
"properties": {
"grpc_code": {
"type": "integer",
"format": "int32"
},
"http_code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
},
"http_status": {
"type": "string"
},
"details": {
"type": "array",
"items": {
"$ref": "#/definitions/protobufAny"
}
}
}
},
"v2EventMsg": {
"type": "object",
"properties": {
"eventID": {
"type": "string"
}
}
}
},
"x-stream-definitions": {
"v2EventMsg": {
"type": "object",
"properties": {
"result": {
"$ref": "#/definitions/v2EventMsg"
},
"error": {
"$ref": "#/definitions/runtimeStreamError"
}
},
"title": "Stream result of v2EventMsg"
}
}
} |
45eca10
to
621e5d1
Compare
This PR allows for reusing schemas stored in x-... extensions of the spec, via json pointers. We have seen some specs using such extensions to create "alternate definitions". The spec flattening canonicalizes such schemas by reintroducing them as #/definitions, so they can be consumed by codegen. * requires: go-openapi/jsonpointer#16 * contributes: go-swagger/go-swagger#1898 Signed-off-by: Frederic BIDON <[email protected]>
6b1acfe
to
887ddcd
Compare
This PR allows for reusing schemas stored in x-... extensions of the spec, via json pointers.
We have seen some specs using such extensions to create "alternate definitions". The spec flattening canonicalizes such schemas by reintroducing them as #/definitions, so they can be consumed by codegen.