Adding Two Versions of Same API to Product in APIC - apiconnect

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

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: ''

Serverless: TypeError: Cannot read property 'stage' of undefined

frameworkVersion: '2'
plugins:
- serverless-step-functions
- serverless-python-requirements
- serverless-parameters
- serverless-pseudo-parameters
provider:
name: aws
region: us-east-2
stage: ${opt:stage, 'dev'}
runtime: python3.7
versionFunctions: false
iam:
role: arn:aws:iam::#{AWS::AccountId}:role/AWSLambdaVPCAccessExecutionRole
apiGateway:
shouldStartNameWithService: true
lambdaHashingVersion: 20201221
package:
exclude:
- node_modules/**
- venv/**
# Lambda functions
functions:
generateAlert:
handler: handler.generateAlert
generateData:
handler: handler.generateDataHandler
timeout: 600
approveDenied:
handler: handler.approveDenied
timeout: 600
stepFunctions:
stateMachines:
"claims-etl-and-insight-generation-${self:provider.stage}":
loggingConfig:
level: ALL
includeExecutionData: true
destinations:
- Fn::GetAtt: ["ETLStepFunctionLogGroup", Arn]
name: "claims-etl-and-insight-generation-${self:provider.stage}"
definition:
Comment: "${self:provider.stage} ETL Workflow"
StartAt: RawQualityJob
States:
# Raw Data Quality Check Job Start
RawQualityJob:
Type: Task
Resource: arn:aws:states:::glue:startJobRun.sync
Parameters:
JobName: "data_quality_v2_${self:provider.stage}"
Arguments:
"--workflow-name": "${self:provider.stage}-Workflow"
"--dataset_id.$": "$.datasetId"
"--client_id.$": "$.clientId"
Next: DataQualityChoice
Retry:
- ErrorEquals: [States.ALL]
MaxAttempts: 2
IntervalSeconds: 10
BackoffRate: 5
Catch:
- ErrorEquals: [States.ALL]
Next: GenerateErrorAlertDataQuality
# End Raw Data Quality Check Job
DataQualityChoice:
Type: Task
Resource:
Fn::GetAtt: [approveDenied, Arn]
Next: Is Approved ?
Is Approved ?:
Type: Choice
Choices:
- Variable: "$.quality_status"
StringEquals: "Denied"
Next: FailState
Default: HeaderLineJob
FailState:
Type: Fail
Cause: "Denied status"
# Header Line Job Start
HeaderLineJob:
Type: Parallel
Branches:
- StartAt: HeaderLineIngestion
States:
HeaderLineIngestion:
Type: Task
Resource: arn:aws:states:::glue:startJobRun.sync
Parameters:
JobName: headers_lines_etl_rs_v2
Arguments:
"--workflow-name.$": "$.Arguments.--workflow-name"
"--dataset_id.$": "$.Arguments.--dataset_id"
"--client_id.$": "$.Arguments.--client_id"
End: True
Retry:
- ErrorEquals: [States.ALL]
MaxAttempts: 2
IntervalSeconds: 10
BackoffRate: 5
Catch:
- ErrorEquals: [States.ALL]
Next: GenerateErrorAlertHeaderLine
End: True
# Header Line Job End
GenerateErrorAlertDataQuality:
Type: Task
Resource:
Fn::GetAtt: [generateAlert, Arn]
End: true
resources:
Resources:
# Cloudwatch Log
"ETLStepFunctionLogGroup":
Type: AWS::Logs::LogGroup
Properties:
LogGroupName: "ETLStepFunctionLogGroup_${self:provider.stage}"
This is what my serverless.yml file looks like.
When I run the command:
sls deploy --stage staging
It show
Type Error ----------------------------------------------
TypeError: Cannot read property 'stage' of undefined
at Variables.getValueFromOptions (/snapshot/serverless/lib/classes/Variables.js:648:37)
at Variables.getValueFromSource (/snapshot/serverless/lib/classes/Variables.js:579:17)
at /snapshot/serverless/lib/classes/Variables.js:539:12
Your Environment Information ---------------------------
Operating System: linux
Node Version: 14.4.0
Framework Version: 2.30.3 (standalone)
Plugin Version: 4.5.1
SDK Version: 4.2.0
Components Version: 3.7.4
How I can fix this? I tried with different version of serverless.
There is error in yamlParser file, which is provided by serverless-step-functions.
Above is my serverless config file.
It looks like a $ sign is missing from your provider -> stage?
provider:
name: aws
region: us-east-2
stage: ${opt:stage, 'dev'} # $ sign is missing?
runtime: python3.7
versionFunctions: false
iam:
role: arn:aws:iam::#{AWS::AccountId}:role/AWSLambdaVPCAccessExecutionRole
apiGateway:
shouldStartNameWithService: true
lambdaHashingVersion: 20201221

How to eliminate serverless framework error Template format error

Testing, learning serverless framework. I'm trying to deploy simple/basic state machine with two simple lambda functions.
Serverless definition as follows:
frameworkVersion: '2'
app: state-machine
org: macdrorepo
service: state-machine
plugins:
- serverless-python-requirements
- serverless-iam-roles-per-function
- serverless-step-functions
- serverless-pseudo-parameters
custom:
pythonRequirements:
dockerizePip: non-linux
slim: true
zip: true
provider:
name: aws
runtime: python3.8
region: eu-central-1
stage: ${opt:stage, 'testing'}
timeout: 30
package:
individually: true
exclude:
- node_modules/**
- .git/**
- .venv/**
functions:
processpurchase:
module: state-machine
memorySize: 128
stages:
- testing
- dev
handler: ProcessPurchase.process_purchase
processrefund:
module: state-machine
memorySize: 128
stages:
- testing
- dev
handler: ProcessRefund.process_refund
stepFunctions:
validate: true
stateMachines:
TransactionChoiceMachine:
name: ChoiceMachineTest-${self:provider.stage}
dependsOn: CustomIamRole
definition:
Comment: "Purchase refund choice"
StartAt: ProcessTransaction
States:
ProcessTransaction:
Type: Choice
Choices:
- Variable: "$.TransactionType"
StringEquals: PURCHASE
Next: PurchaseState
- Variable: "$.TransactionType"
StringEquals: REFUND
Next: RefundState
PurchaseState:
Type: Task
Resource:
Fn::GetAtt: [processpurchase, Arn]
End: true
RefundState:
Type: Task
Resource:
Fn::GetAtt: [processrefund, Arn]
End: true
During deploy, sls is saying my state machine definition is ok: State machine "TransactionChoiceMachine" definition is valid
My environment information:
Your Environment Information ---------------------------
Operating System: linux
Node Version: 12.20.0
Framework Version: 2.14.0
Plugin Version: 4.1.2
SDK Version: 2.3.2
Components Version: 3.4.3
Setup SLS_DEBUG=* is not helping me much as I do not know js unfortunately.
After serverless deploy command, I'm getting error:
Error: The CloudFormation template is invalid: Template format error: Unresolved resource dependencies [CustomIamRole] in the Resources block of the template
Looks like you are referencing something called CustomIamRole in your state machine creation but I cannot see it being created anywhere in the yaml file. Either create the role and use it in creation or remove the depends on part.

How to run a Kotlin server generated by Swagger Codegen?

I am unable to run the kotlin-server generated by Swagger Codegen v. 3.
The .yaml file is:
openapi: 3.0.0
info:
title: Experiement with Swagger
description: Test
version: 1.0.0
servers:
- url: 'http://localhost:8080'
description: production server's url
tags:
- name: Test
description: Test
externalDocs:
description: Find out more
url: 'http://localhost:8080'
paths:
/testURI:
post:
tags:
- Test
summary: Test
description: Test
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Test'
responses:
'200':
description: Test success
content:
application/json:
schema:
$ref: '#/components/schemas/TestSuccessResponse'
'404':
description: >-
Only a signed in user can add a question. This response means that
the user isn't signed in.
content:
application/json:
schema:
$ref: '#/components/schemas/UnauthorisedErrorResponse'
'500':
description: >-
means some internal error occur on the server while doing the
operation. The state of the operation if un-determined and the
operation could be succesful, failed or partially successful
(because some database operations are not rolled back if error
occurs!
content:
application/json:
schema:
$ref: '#/components/schemas/InternalServerErrorResponse'
components:
schemas:
Test:
type: object
properties:
some-input:
type: string
TestSuccessResponse:
type: object
properties:
result:
type: string
enum:
- success
additional-info:
type: string
enum:
- Test successful
required:
- result
- additional-info
UnauthorisedErrorResponse:
type: object
properties:
result:
type: string
enum:
- error
additional-info:
type: string
enum:
- Not authorised
required:
- result
- additional-info
InternalServerErrorResponse:
type: object
properties:
result:
type: string
enum:
- error
additional-info:
type: string
enum:
- Internal Server Error
required:
- result
- additional-info
I pasted it into Swagger Editor, downloaded the kotlin-server kotlin-server-server-generated.zip, unzipped it at C:\Users\manu\Documents\manu\kotlin-server-server-generated, opened Readme.MD file and followed the instructions in it.
Using Windows cmd, in C:\Users\manu\Documents\manu\kotlin-server-server-generated,
first I ran gradle wrapper.
I got this output:
Starting a Gradle Daemon, 1 incompatible and 2 stopped Daemons could not be reused, use --status for details
Build cache is an incubating feature.
BUILD SUCCESSFUL in 17s
1 actionable task: 1 executed
Then I ran gradlew check assemble:
C:\Users\manu\Documents\manu\kotlin-server-server-generated>gradlew check assemble
Starting a Gradle Daemon, 1 incompatible and 2 stopped Daemons could not be reused, use --status for details
Build cache is an incubating feature.
w: C:\Users\manu\Documents\manu\kotlin-server-server-generated\src\main\kotlin\io\swagger\server\apis\TestApi.kt: (51, 9): Variable 'gson' is never used
w: C:\Users\manu\Documents\manu\kotlin-server-server-generated\src\main\kotlin\io\swagger\server\apis\TestApi.kt: (52, 9): Variable 'empty' is never used
Task :startShadowScripts
Using TaskInputs.file() with something that doesn't resolve to a File object has been deprecated and is scheduled to be removed in Gradle 5.0. Use TaskInputs.files() instead.
BUILD SUCCESSFUL in 36s
10 actionable tasks: 10 executed
Then I ran java -jar ./build/libs/kotlin-server.jar.
But when I pointed the browser to localhost:8080, I see Page Not Found.
What am I doing wrong?

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

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: