Hi,
we're trying to model our domain and API with swagger. We use a 2-level
inheritance model and do get different generation results from swagger
online editor and offline swagger 2.2.1 generation (library for generation
is Spring).
An abstracted example is shown in the following yaml:
swagger: '2.0'
info:
title: API of something
description: API
version: "1.0.0"
host: localhost:8081
schemes:
- http
basePath: /api/v1
produces:
- application/json
consumes:
- application/json
paths:
/implementations:
get:
description: Get all impls
responses:
200:
description: An array of all impls
schema:
type: array
items:
$ref: '#/definitions/Implementation'
definitions:
Implementation:
allOf:
- $ref: '#/definitions/BaseType'
- type: object
properties:
metaData:
type: string
BaseType:
allOf:
- $ref: '#/definitions/IdObject'
- type: object
- discriminator: baseType
properties:
baseType:
type: string
property:
type: string
required:
- baseType
IdObject:
discriminator: idObjectType
properties:
idObjectType:
type: string
id:
type: integer
format: int64
required:
- idObjectType
- id
Summarized inheritance: Implementation extends BaseObject extends IdObject
The generated code for the model class Implementation is correctly formed
when generating with online swagger editor (Implementation extends
BaseObject) but not for offline generation using command line
swagger-codegen generate -i oath/to/api.yaml -l spring -o /tmp/test/
Using offline generation BasObject extends IdObject but Implementation is
not extending BaseObject (the "extends BaseObject" phrase is missing).
2 questions:
- Is it possible and good practice to use an inheritance structure like we
try to do?
- Is online code generation using a different generator version or
parameter set?
Thank you,
Stefan
--
You received this message because you are subscribed to the Google Groups
"Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.