-
Notifications
You must be signed in to change notification settings - Fork 200
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
Swagger inheritance is broken #1050
Comments
I did another test. I replaced the interfaces with actual classes. Now enunciate generates a different swagger.json here is how the swagger.json looks if i replace the interfaces with classes. "CommunicationLink": {
"type": "object",
"title": "CommunicationLink",
"properties": {
"commonField": {
"readOnly": false,
"description": "",
"type": "string"
}
}
},
"Email": {
"type": "object",
"title": "Email2",
"allOf": [
{
"$ref": "#/definitions/CommunicationLink"
},
{
"properties": {
"emailAddress": {
"readOnly": false,
"description": "",
"type": "string"
}
}
}
]
},
"Telephone": {
"type": "object",
"title": "Telephone",
"allOf": [
{
"$ref": "#/definitions/CommunicationLink"
},
{
"properties": {
"telephonenumber": {
"readOnly": false,
"description": "",
"type": "string"
}
}
}
]
} |
I think I found the solution.
If I add this line manually the generated client uses inheritance as well and my code is working. I'm not sure why you tread interface inheritance diffrent than class inheritance. Is this because of this: #374 So finally here is how the swagger.json definitions section should look like: "CommunicationLink": {
"discriminator": "type",
"type": "object",
"title": "CommunicationLink",
"properties": {
"commonField": {
"readOnly": false,
"description": "",
"type": "string"
}
},
},
"Email": {
"type": "object",
"title": "Email2",
"allOf": [
{
"$ref": "#/definitions/CommunicationLink"
},
{
"properties": {
"emailAddress": {
"readOnly": false,
"description": "",
"type": "string"
}
}
}
]
},
"Telephone": {
"type": "object",
"title": "Telephone",
"allOf": [
{
"$ref": "#/definitions/CommunicationLink"
},
{
"properties": {
"telephonenumber": {
"readOnly": false,
"description": "",
"type": "string"
}
}
}
]
} |
Fixed at 5184d70. Note that the interface "superclass" (in this case |
Fixed in |
It seems like the generated swagger file does not know about inheritance wich makes my generated client unusable.
My example rest api looks like this:
We use immuables to generate pojos so please ignore that these are all interfaces
I used the swagger.json to generate a java client. I tried to call my service like that:
It seems like the inheritance is not translated into the generated swagger.json.
This is what enunciate generated (only the relevant parts of the section "definitions")
The text was updated successfully, but these errors were encountered: