swagger-api / swagger-api/swagger-codegen

Missing JsonSubTypes in Swagger Code Gen for jaxrs-jersey

Open
#9,417 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Below is the sample yaml with Inheritance and Polymorphism. While generating server stubs for JAXRS-JERSEY. Model objects doesn't contain @JsonTypeInfo and @JsonSubTypes . Is this supported in latest swagger-codegen-cli-3.0.5.jar ?

openapi: "3.0.0"
info:
description: "This is a sample server Petstore server."
version: "1.0.0"
title: "Swagger Petstore"
termsOfService: "http://swagger.io/terms/"
tags:
•name: "pets"
description: "Everything about your Pets"
paths:
/pets:
patch:
requestBody:
content:
application/json:
schema:
oneOf:

  • $ref: '#/components/schemas/Cat'
  • $ref: '#/components/schemas/Dog'
    discriminator:
    propertyName: pet_type
    responses:
    '200':
    description: Updated
    components:
    schemas:
    Pet:
    type: object
    required:
  • pet_type
    properties:
    pet_type:
    type: string
    discriminator:
    propertyName: pet_type
    mapping:
    cachorro: Dog
    Cat:
    allOf:
  • $ref: '#/components/schemas/Pet'
  • type: object

all other properties specific to a Cat

properties:
name:
type: string
Dog:
allOf:

  • $ref: '#/components/schemas/Pet'
  • type: object

all other properties specific to a Dog

properties:
bark:
type: string
Lizard:
allOf:

  • $ref: '#/components/schemas/Pet'
  • type: object

all other properties specific to a Lizard

properties:
lovesRocks:
type: boolean

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Run the supplied inheritance and polymorphism YAML through swagger-codegen-cli-3.0.5.jar with the jaxrs-jersey generator, then inspect the generated model objects. Done means the generated models include the expected @JsonTypeInfo and @JsonSubTypes annotations for the Pet, Cat, Dog, and Lizard schemas.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.