OpenAPI (3.0) и полиморфизм в клиентеJAVA

Программисты JAVA общаются здесь
Anonymous
OpenAPI (3.0) и полиморфизм в клиенте

Сообщение Anonymous »

Я пытаюсь моделировать наследование в OpenAPI 3. Я не понимаю, почему перемещение модельных определений из определений: в компоненты: схемы: вызывает наследство больше не моделируется. В конечном счете, я бы хотел клиентов DART, но успешно выполнил только наследство для Java, и только тогда для 2.0 OpenApi Spec. < /P>
работа: < /p>

Код: Выделить всё

java -jar swagger-codegen-cli-3.0.68.jar generate -i swagger.yaml -l java -o ./_swagger
< /code>
с: < /p>
components:
schemas:
Pet:
discriminator: petType
required:
- name
- petType # required for inheritance to work
properties:
name:
type: string
petType:
type: string
Cat:
allOf:
- $ref: '#/definitions/Pet' # Cat has all properties of a Pet
- properties: # extra properties only for cats
huntingSkill:
type: string
default: lazy
enum:
- lazy
- aggressive
Dog:
allOf:
- $ref: '#/definitions/Pet' # Dog has all properties of a Pet
- properties: # extra properties only for dogs
packSize:
description: The size of the pack the dog is from
type: integer
openapi: 3.0.3
security: []
servers: []
paths:
< /code>
производит < /p>
public class Dog { ...}
Но со следующим (взято из рабочего примера в https://github.com/swagger-api/swagger- ... ssues/6148) и использует определения (против компонентов/схемы) ...

Код: Выделить всё

swagger: "2.0"
basePath: "/v2"
definitions:
Pet:
discriminator: petType
required:
- name
- petType # required for inheritance to work
properties:
name:
type: string
petType:
type: string
Cat:
allOf:
- $ref: '#/definitions/Pet' # Cat has all properties of a Pet
- properties: # extra properties only for cats
huntingSkill:
type: string
default: lazy
enum:
- lazy
- aggressive
Dog:
allOf:
- $ref: '#/definitions/Pet' # Dog has all properties of a Pet
- properties: # extra properties only for dogs
packSize:
description: The size of the pack the dog is from
type: integer
< /code>
Я получаю: < /p>
public class Dog extends Pet { }
Как меня генерировать наследование в OpenApi3?

Подробнее здесь: https://stackoverflow.com/questions/796 ... the-client

Вернуться в «JAVA»