Validation error with api connect on bluemix: Data does not match any schemas from 'oneOf' - api

I'm getting the error Data does not match any schemas from 'oneOf' with the following spec:
product: 1.0.0
info:
name: account-information
title: Account Information
version: 1.0.10
termsOfService: >-
These API are a PSD2 implementation example. The service might be
discontinued at any time
visibility:
view:
type: public
subscribe:
type: authenticated
plans:
premium:
title: Premium
apis: {}
rate-limit:
value: 1000/1minute
hard-limit: true
approval: true
default:
title: Default Plan
description: Default Plan
approval: false
rate-limit:
value: 100/hour
hard-limit: true
apis:
account:
$ref: account.yaml
subscription:
$ref: subscription.yaml
The full error message:
Message : "Data does not match any schemas from "oneOf"", Chemin de données : "", Chemin de schéma : "/oneOf"
Message : "Additional properties not allowed", Chemin de données : "/name", Chemin de schéma : "/oneOf/0/additionalProperties"
I don't understand where does the error come from and how to solve it.

For API Connect I believe you want to use x-ibm-name instead of name. I was able to get the following spec validated using your above example:
info:
title: Account Information
x-ibm-name: account-information
version: 1.0.10
visibility:
view:
type: public
subscribe:
type: authenticated
plans:
premium:
title: Premium
apis: {}
rate-limit:
value: 1000/1minute
hard-limit: true
approval: true
default:
title: Default Plan
description: Default Plan
approval: false
rate-limit:
value: 100/hour
hard-limit: true
apis:
account:
$ref: account.yaml
subscription:
$ref: subscription.yaml
Note: I also removed the product field.
You could also use the Design tab to have API Connect create the source automatically in the correct format:

Related

Swagger 2.0 Parser error duplicated mapping key

Parser error, duplicated mapping key, Jump to line 52
Issues while adding common parameter id
Line 44 is over-indented. Replace
/tasks/{id}:
get:
with
/tasks/{id}:
get:
There was a lot to fix.
There were multiple parameters defined in one operation.
The path /tasks/{id} was defined multiple times.
=> You have to use once and put each http-method inside this path.
I tried my best to create the YAML and I hope I fixed it correctly.
It's much easier to do such stuff, if the complete code is part of the question.
openapi: 3.0.1
info:
title: Sample API v2
description: Sample Data API v2
contact:
name: John Smith
email: john.smith#email.com
version: v2
servers:
- url: https://task-manager-pvs.herokuapp.com/
paths:
/tasks:
get:
tags:
- Tasks
summary: Get All Tasks
operationId: GetAllTasks
parameters: []
responses:
'200':
description: ''
headers: {}
deprecated: false
security: []
post:
tags:
- Tasks
summary: Create Task
operationId: CreateTask
parameters: []
requestBody:
description: ''
content:
application/json:
schema:
$ref: '#/components/schemas/CreateTaskRequest'
example:
name: test
required: true
responses:
'200':
description: ''
headers: {}
deprecated: false
security: []
/tasks/{id}:
get:
tags:
- Single Task
parameters:
- name: id
in: path
required: true
schema:
type: string
description: The Task ID
summary: Get Single Task
operationId: GetSingleTask
responses:
'200':
description: ''
headers: {}
deprecated: false
security: []
patch:
tags:
- Single Task
summary: Update Task
parameters:
- in: path
name: id
schema:
type: string
required: true
description: The Task ID
operationId: UpdateTask
requestBody:
description: ''
content:
application/json:
schema:
$ref: '#/components/schemas/UpdateTaskRequest'
example:
name: st
required: true
responses:
'200':
description: ''
headers: {}
deprecated: false
security: []
delete:
parameters:
- in: path
name: id
schema:
type: string
required: true
description: The Task ID
tags:
- Single Task
summary: Delete Task
operationId: DeleteTask
responses:
'200':
description: ''
headers: {}
deprecated: false
security: []
components:
schemas:
CreateTaskRequest:
title: CreateTaskRequest
required:
- name
type: object
properties:
name:
type: string
example:
name: test
UpdateTaskRequest:
title: UpdateTaskRequest
required:
- name
type: object
properties:
name:
type: string
example:
name: st
tags:
- name: Tasks
description: ''
- name: Single Task
description: ''

Adding Two Versions of Same API to Product in APIC

I am using IBM API Connect v5. We have an API with two different versions, 1.0.0 and 2.0.0. We have both APIs inside a single Product. From APIMgr we are able to stage and deploy the Product to Marketplace. However, when running CLI we get an error like the below:
"\u001b[31mError:\u001b[39m The Plan Default Plan refers to an API team-api:1.0.0 which is not present in the product."
The product yaml looks like the below
product: "1.0.0" info: name: "team-product" title: "Team Product"
version: "1.0.0" visibility: view:
enabled: true
type: "public"
tags: []
orgs: [] subscribe:
enabled: true
type: "authenticated"
tags: []
orgs: [] apis: team-api:
$ref: "team-api_1.0.0.yaml" team-api_1:
$ref: "team-api_2.0.0.yaml" plans: default:
title: "Default Plan"
description: "Default Plan"
approval: false
rate-limit:
hard-limit: false
value: "100/hour"
Does anyone know how to specify the APIs explicitly in the Product yaml file so that when running apic publish from CLI this error does not occur?
A Product can have many APIs (but remember, when you deploy a one version the second version will also be deployed! Accordingly, there will be downtime for both versions)
We have APIC v5 and use yaml like this:
product: 1.0.0
info:
name: test-datapower-product
title: Test-DataPower product
version: 1.0.0
visibility:
view:
enabled: true
type: public
tags: []
orgs: []
subscribe:
enabled: true
type: authenticated
tags: []
orgs: []
apis:
api-first-version:
id: 5f04285fe4b0e12ae4d9803f
api-second-version:
id: 5fb2b1aee4b0cab276cdafc1
plans:
default:
title: Default Plan
description: Default Plan
approval: false
rate-limit:
hard-limit: true
value: 100/hour

How to nest a JSON payload under a named parameter in open api 3.0 [duplicate]

This question already has answers here:
Swagger: How to have a property reference a model in OpenAPI 2.0 (i.e. nest the models)?
(2 answers)
Closed 2 years ago.
I'm trying to describe an API endpoint that receives a PUT request with the following JSON payload:
{
"product": {
"name: "foo",
"brand": "bar"
}
}
Here is a sample of the definition:
components:
schemas:
Product:
type: object
required:
- name
- brand
properties:
name:
type: string
brand:
type: string
paths:
/products/{id}:
parameters:
- name: id
in: path
schema:
type: integer
required: true
put:
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Product'
However, this produces the following JSON payload (it's missing the "product" key):
{
"name: "foo",
"brand": "bar"
}
I tried this:
parameters:
- name: product
in: body
schema:
type: object
properties:
product:
type: object
schema:
$ref: '#/components/schemas/Product'
But that doesn't work. Any ideas?
Your second example is almost correct, just change this part
schema:
type: object
properties:
product:
type: object
schema:
$ref: '#/components/schemas/Product'
to
schema:
type: object
properties:
product:
$ref: '#/components/schemas/Product'
Note the $ref is used directly under the property name.

Swagger-YAML Bad Mapping entry in my oppproduct

I am having a problem with the path. The error that i am getting is the following check image below. I tried with the link that was pointed out by a community member #Helen Paths and no luck. Please help me out.
Thanks,
Darko
/opportunity/{opportunityid}/oppproduct/{oppproductid}:
get:
tags:
- "Opportunity"
summary: "Get opp product id for certain opportunity"
description: "This endpoint displays opp product details"
produces:
- "application/json"
parameters:
- name: "opportunityid"
in: "path"
description: "This is unique identifier of specific opportunity"
required: true
type: "string"
- name: "oppproductid"
in: "path"
description: "This is unique identifier of specific opp product in specific opportunity "
required: true
type: "string"
responses:
200:
description: "successful operation"
schema:
type: "array"
items:
$ref: "#/definitions/opportunity"
400:
description: "Invalid status value"
put:
tags:
- "Opportunity"
summary: "Update opportunity product from specific opportunity"
description: "Update this opportunity product."
operationId: "updateOppProduct"
produces:
- "application/json"
parameters:
- name: "opportunityid"
in: "path"
description: "Opportunity product with id that need to be updated"
required: true
type: "string"
responses:
400:
description: "Invalid Opportunity product supplied"
404:
description: "Opportunity product not found"
error that i am getting.
1) "Duplicated mapping key" error indicates you have duplicate keys in one of the parameters, specifically two name keys. You only need one name:
parameters:
- name: "opportunityid" # <---------
in: "path"
description: "Opportunity product with id that need to be updated"
required: true
type: "string"
name: "oppproductid" # <---------
2) The other error is caused by the schema keyword in a path parameter:
- in: "path"
description: "Updated Opp product object"
type: "string" # <--- This is the correct way to specify the param type in OAS 2.0
required: true
schema: # <--------- Remove this
type: integer
You don't need schema here. In OpenAPI 2.0, path, query and header parameters use type directly without the schema keyword.

Create bigquery table using google cloud deployment manager YAML file

I am trying to create a big query table using the deployment manager by following YAML file :
imports:
- path: schema.txt
resources:
- name: test
type: bigquery.v2.table
properties:
datasetId: test_dt
tableReference:
datasetId: test_dt
projectId: test_dev
tableId: test
schema:
fields: {{ imports["schema.txt"] }}
However, when I try to give the table schema definition via .txt file I get a parsing error. If I give the schema definition instead of .txt file then the script runs successfully. This method of importing the text file is given in the google cloud help. Can anyone help me with this?
I think the way the deployment manager is formatting the contents of the .txt file might be incorrect. A good way to debug this would be to collect HTTP request traces and comparing the difference between the two requests.
this is yaml we could get working using nested or repeated field in bigquery deployment manager.
# Example of the BigQuery (dataset and table) template usage.
#
# Replace `<FIXME:my_account#email.com>` with your account email.
imports:
- path: templates/bigquery/bigquery_dataset.py
name: bigquery_dataset.py
- path: templates/bigquery/bigquery_table.py
name: bigquery_table.py
resources:
- name: dataset_name_here
type: bigquery_dataset.py
properties:
name: dataset_name_here
location: US
access:
- role: OWNER
userByEmail: my_account#email.com
- name: table_name_here
type: bigquery_table.py
properties:
name: table_name_here
datasetId: $(ref.dataset_name_here.datasetId)
timePartitioning:
properties:
field:
type: DAY
schema:
- name: column1
type: STRUCT
fields:
- name: column2
type: string
- name: test1
type: RECORD
mode: REPEATED
fields:
- name: test2
type: string
Sample YAML for Creating View in BigQuery using Deployment manager:
Note: This YAML also shows how to create partitioning(_PARTITIONTIME) on a table (hello_table)
# Example of the BigQuery (dataset and table) template usage.
# Replace `<FIXME:my_account#email.com>` with your account email.
imports:
- path: templates/bigquery/bigquery_dataset.py
name: bigquery_dataset.py
- path: templates/bigquery/bigquery_table.py
name: bigquery_table.py
resources:
- name: dataset_name
type: bigquery_dataset.py
properties:
name: dataset_name
location: US
access:
- role: OWNER
userByEmail: my_account#email.com
- name: hello
type: bigquery_table.py
properties:
name: hello_table
datasetId: $(ref.dataset_name.datasetId)
timePartitioning:
type: DAY
schema:
- name: partner_id
type: STRING
- name: view_step
type: bigquery_table.py
properties:
name: hello_view
datasetId: $(ref.dataset_name.datasetId)
view:
query: select partner_id from `project_name.dataset_name.hello_table`
useLegacySql: False