RAML 0.8 multiples responses

I am trying to convert and OpenAPI spec to RAML 0.8.

The definition in OpenAPI is as follows

'200':
            description: Ok
            content:
              application/json:
                schema:
                  anyOf:
                    - $ref: '#/components/schemas/schemaA'
                    - $ref: '#/components/schemas/schemaB'

How would I define it in the RAML?
I have tried:
1.
> responses:

      200:
        description: Ok
        body:
          application/json:
            schema: schemaA | schemaB
responses:
      200:
        description: Ok
        body:
          application/json:
            schema: schemaA
         application/json+B:
            schame: schemaB

In case of 2, the schema is valid, but would Mule understand a custom json type?

Why not use RAML 1.0 instead? In that case the union (1.) would work.

If you REALLY insist on using RAML 0.8, you can move your anyOf: to a separate JSON Schema that either $refers to or includes both schemaA and schemaB and then you would refer to it with an !include. I.e. schema: !include JSONSchemaWithAnyOf.json.

Hope this helps!

Thanks @jstoiko. Can’t really move to 1.0 yet; its a constrain I have. Your suggestion also work, but I wanted to know if there was any other alternative.

@jstoiko, sorry to bother you, am getting an warning after trying to modify the file.

{
	"$schema": "http://json-schema.org/draft-04/schema#",
	"type": "object",
	"required": ["response"],
	"properties": {
		"response": {
			"type": "object",
			"oneOf": [
        {
					"$ref": "schemaA.json"
				},
				{
					"$ref": "schemaB.json"
				}
			]
		}
	}
}

Error is:
‘Can not parse JSON example: Unexpected end of JSON input’

Any idea what is wrong?

“Unexpected end of JSON input” indicates a JSON formatting error. You may want to check the syntax.

Thanks, @jstoiko. Solved the problem last evening just forgot to update it here.

Solution looks like

{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"required": ["response"],
"properties": {
	"response": {
		"type": "object",
		"oneOf": [
    {
				"$ref": "./schemaA.json"
			},
			{
				"$ref": "./schemaB.json"
			}
		]
	}
}

}

Hi, My requirement is, in POST method, i can expect multiple XML file.
Can you please help me, how can i declare multiple schema file in RAML file.

/icimscccnh:
post:
securedBy: [basic]
body:
application/xml:
schema: !include Request1.xsd
schema: !include Request2.xsd

@biswa_tripathy, what is your use case. I don’t think there is ever a scenario when you can respond with 2 schemas unless you have a condition!

Thanks a lot for your reply Vivek.

My API POST method should be able to accept two different XML structure.
Can you please help me, how can i define two schema file, so that any XML will come, it should take anyOf the schema .

Have a look at the documentation

https://swagger.io/docs/specification/data-models/oneof-anyof-allof-not/

Thanks a lot Vivek, Can we achieve the same using RAML ?

Absolutely, have a look at a response for my question i posted a couple of weeks ago

Vivek sorry for late reply, That project was on hold for 3 months, now back into track, but still my issue persist.

I have two schema files SchemaA.json and SechemaB.json, I want to mention that in post method schema declaration, Either message of SchemaA or SchemaB will come, our service should validate and proceed, any other structure, it should throw error.

I am open for RAML 1.0 also, i tried to use union, it is not working, Can you please help me here?

Can you share you example? If you are using RAML 1, it’s should be easy.

Also, what is the error you are seeing?