Skip to content
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

Schema property "implementation" prints the whole object instead of $ref in "/openapi" #14075

Closed
shankar6477 opened this issue Sep 22, 2020 · 2 comments
Labels
bug This bug is not present in a released version of Open Liberty in:MicroProfile/OpenAPI

Comments

@shankar6477
Copy link

Describe the bug
Adding the property "implementation" in Schema prints the whole object's structure instead of "$ref".

Example :
@Schema(name = "paymentInformation", type = SchemaType.ARRAY, minItems = 1, maxItems = 1, implementation = PaymentInstruction.class)
@NotNull
@SiZe(min=1, max=1)
private @Valid List paymentInformation = new ArrayList();

Steps to Reproduce
Add property "implementation" to an ArrayList of user defined class.
@Schema(name = "paymentInformation", type = SchemaType.ARRAY, minItems = 1, maxItems = 1, implementation = PaymentInstruction.class)
@NotNull
@SiZe(min=1, max=1)
private @Valid List paymentInformation = new ArrayList();

Expected behavior
Openapi should refer to the existing object using $ref instead of printing the whole object
This is the snippet without implementation class (using $ref)
@Schema(name = "payment_information", type = SchemaType.ARRAY, minItems = 1, maxItems = 1)
private @Valid List paymentInformation = new ArrayList<>();
payment_information:
maxItems: 1
minItems: 1
type: array
description: payment info
items:
type: array
description: payment info
items:
$ref: '#/components/schemas/PaymentInstruction'

This is post adding implementation class
@Schema(name = "payment_information", type = SchemaType.ARRAY, minItems = 1, maxItems = 1, implementation = PaymentInstruction.class)
private @Valid List paymentInformation = new ArrayList<>();
payment_information:
maxItems: 1
minItems: 1
type: array
description: payment info
items:
maxItems: 1
required:
- credit_transfer_transaction_information
- debtor
- debtor_account
- payment_information_identification
type: object
properties:
payment_information_identification:
maxLength: 35
minLength: 1
type: string
description: Unique identification, as assigned by a sending party,
to unambiguously identify the payment information group within
the message
example: 1047658536..............

Diagnostic information:

  • OpenLiberty Version: 20.0.0.6
  • Java Version: java version "1.8.0"
    Java(TM) SE Runtime Environment (build pwa6480sr2fp10ifix-20160223_01(SR2 FP10+IV81318+IV81645+IV81741+IV81716))
    IBM J9 VM (build 2.8, JRE 1.8.0 Windows 10 amd64-64 Compressed References 20160210_289934 (JIT enabled, AOT enabled)
    J9VM - R28_Java8_SR2_20160210_1617_B289934
    JIT - tr.r14.java_20151209_107110.04
    GC - R28_Java8_SR2_20160210_1617_B289934_CMPRSS
    J9CL - 20160210_289934)
    JCL - 20151231_01 based on Oracle jdk8u71-b15
  • server.xml configuration
jsp-2.3 microProfile-3.0 jaxb-2.2
<!-- To access this server from a remote client add a host attribute to the following element, e.g. host="*" -->
<httpEndpoint id="defaultHttpEndpoint"
              httpPort="9080"
              httpsPort="9443" />
<!-- Automatically expand WAR files and EAR files -->
<applicationManager autoExpand="true"/>
- If it would be useful, upload the messages.log file found in `$WLP_OUTPUT_DIR/messages.log`

Additional context
Add any other context about the problem here.

@shankar6477 shankar6477 added the bug This bug is not present in a released version of Open Liberty label Sep 22, 2020
@msmiths
Copy link
Contributor

msmiths commented Sep 23, 2020

@shankar6477 This issue is working as designed. The schema will always be inlined (rather than using $ref) because it is not a simple usage of the implementation attribute on the @Schema annotation, i.e., the inclusion of other attributes (minItems and maxItems in this case) effectively means that a new schema is being defined.

However, this issue can be avoided when using the mpOpenAPI-2.0 feature by not including the implementation attribute on the @Schema annotation.

mpOpenAPI-2.0 is included as beta in the upcoming OpenLiberty 20.0.0.11 release.

Please see the following PR for details: #13589.

@tevans78
Copy link
Member

tevans78 commented May 17, 2021

Closing as working as designed, please re-open if you disagree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This bug is not present in a released version of Open Liberty in:MicroProfile/OpenAPI
Projects
None yet
Development

No branches or pull requests

4 participants