OneOf property is failing during OAS Schema Validation
RPS044 opened this issue · comments
Hello Team,
Requesting you to please check this issue and help. Performing a validation against respective schema with oneOf, discriminator and mapping property in oas3.0 and validating the fields (if fields are missed then throws 4** errors).
Error:
{
"fault": {
"faultstring": "OASValidation MAM-EXT-SpecValidation with resource "oas://openapi.yaml": failed with reason: "[ERROR - An error occurred during schema validation - com.google.common.util.concurrent.UncheckedExecutionException: java.lang.NullPointerException.: []]"",
"detail": {
"errorcode": "steps.oasvalidation.Failed"
}
}
}
yaml file looks like:
Json payload looks like:
{
"billableHeader":{
"sourceSystem":"UPSTREAM_APP",
"sourceTransactionType":"INVOICE",
"eventType":"BATCH",
"messageCreationDatetime":"20220811140203",
"timeZoneCode":"GMT",
"isBulkProcessing":true,
"product":"Airlcl"
}
}
I think you're going to need to go to the particular OAS implementation you're using and ask them. This repo (and organization) manages the JSON Schema spec itself, not any particular library.
Some other things to note:
- OAS 3.0 uses its own flavor of JSON Schema that's based on but isn't exactly draft 4.
discriminator
is an OAS-only thing.
When you file an issue with them, see if you can replicate the problem with a small example, and provide that to them. Just posting the error without context isn't helpful.
Sorry we can't be of more help.
@gregsdennis could you please check now
components:
schemas:
BillableItemsPost:
title: Billable Items Post Request
description: Object defines JSON schema of SAP OTC Billable Items post request
type: object
discriminator:
propertyName: product
mapping:
Generic: '#/components/schemas/BillableItemsPost'
properties:
billableHeader:
description: Billable Item request header
type: object
additionalProperties: false
properties:
product:
description: A discriminator property to identify the schema specifics
type: string
enum:
- Generic
- Airlcl
example: Generic
discriminator:
propertyName: product
mapping:
Generic: '#/components/schemas/BillableItemsPost'
sourceSystem:
description: Upstream System Name **Required for CW1**
type: string
minLength: 1
maxLength: 6
example: GCSS
sourceTransactionType:
description: >-
Source Transaction Type(O- Booking Confirmed, L- Issue Verify
Copy or Pre- Invoice Event, I- Invoice) **Required for CW1**
type: string
enum:
- BOOKING_CONFIRMED
- ISSUE_VERIFY_COPY
- INVOICE
- CREDIT
- CREATE_REV
- UPDATE_REV
- CANCEL_REV
- UPDATE_COST
- CANCEL_COST
- CANCEL_INVOICE
example: INVOICE
eventType:
description: Event Type (Ad-hoc, Batch)
type: string
enum:
- AD-HOC
- BATCH
example: BATCH
messageCreationDatetime:
description: >-
Message Creation Timstamp, used for the message synchronizing to
ensure message is picked in correct sequence **Required for
CW1**
type: string
format: timestamp
example: '20220811140203'
timeZoneCode:
description: >-
Time Zone, Will be used if needed along-with TimeStamp
**Required for CW1**
type: string
minLength: 1
maxLength: 4
example: GMT
isBulkProcessing:
paths:
/billable-items:
post:
summary: Create Billable Item
description: Creates a new Billable Item in S/4 HANA
tags:
- Billable Item
operationId: billable-item-post
requestBody:
content:
application/json:
schema:
x-field-extra-annotation: '@com.fasterxml.jackson.annotation.JsonTypeInfo(
use = com.fasterxml.jackson.annotation.JsonTypeInfo.Id.NAME,
include = com.fasterxml.jackson.annotation.JsonTypeInfo.As.PROPERTY,
property = "product")'
x-class-extra-annotation: '@com.fasterxml.jackson.annotation.@JsonSubTypes({
@JsonSubTypes.Type(value = BillableItemsPost.class, name = "Generic"),
@JsonSubTypes.Type(value = BillableItemsPostAirlcl.class, name = "Airlcl")})'
oneOf:
- $ref: '#/components/schemas/BillableItemsPost'
- $ref: '#/components/schemas/BillableItemsPostAirlcl'
discriminator:
propertyName: product
mapping:
Generic: '#/components/schemas/BillableItemsPost'
Airlcl: '#/components/schemas/BillableItemsPostAirlcl'
@RPS044 I don't think you read my response. This isn't something we can help with here. You need to open an issue with the OpenAPI library you're using.
@gregsdennis you should close this one