RAML not showing expected response in Design Centre vs Open api ( swagger ) for XML data - mulesoft

I am trying to design my api in RAML (In Anypoint platform >> Design centre )
Here is an exceprt of my RAML :
#%RAML 1.0 Extension
title: ABC
version: v2
uses:
types: data-types/types.raml
/{code}:
get:
description: Return employee details
responses:
200:
description: The employee details
body:
application/json: types.employeeDetailList
application/xml: types.employeeDetailList
types.employeeDetailList :
#%RAML 1.0 Library
types:
employeeDetailList:
type: array
xml:
name: 'empUnitList'
prefix: 'emp'
namespace: 'http://www.google.com/xsd'
wrapped: true
items:
type: employeeDetail
employeeDetail:
type: object
xml:
name: empName
prefix: emp
wrapped: true
properties:
code:
type: string
example:
"16"
However in design centre it shows incorrectly as :
<?xml version="1.0" encoding="UTF-8"?>
<empUnitList>
<emp:empUnit>
<code>16</code>
</emp:empUnit>
</empUnitList>
However when I do the same in swagger editor - it shows up correctly :
<?xml version="1.0" encoding="UTF-8"?>
<emp:empUnitList xmlns:org="http://www.google.com/xsd">
<emp:empUnit>
<code>16</code>
</emp:empUnit>
</emp:empUnitList>
I cannot use swagger editor I need to use Anypoint Platform design centre and the response in XML is not showing up correctly ...

Related

Google Appengine Standard : Java8 Setting up Endpoints with IAP and ESP

I am working on a web application that runs on Google Appengine and is able to be accessed from Android app that will synchronise some data from the server. I had this working smoothly until recent when I recreated the project on GCP and setup IAP, which works fine.
However, I am not able to configure the end point, where I keep getting 500 Server Error. I have followed every step in this online instructions from Google https://cloud.google.com/endpoints/docs/openapi/get-started-app-engine-standard and not able to figure out what am I doing wrong!!
Here are the contents of my files:
Echo.java
package com.example.endpoints;
import ...
#Api(
name = "echo",
version = "v1",
clientIds = { IAP_CREATED_WEBCLIENTID_FROM_CREDENTIALS, Constant.API_EXPLORER_CLIENT_ID},
audiences = {IAP_CREATED_WEBCLIENTID_FROM_CREDENTIALS},
namespace = #ApiNamespace(
ownerDomain = "com.example.endpoints",
ownerName = "com.example.endpoints",
packagePath = "")
)
public class Echo {
#ApiMethod(name = "echoonly", path = "/echo/v1/echoonly")
public Entity echoonly() {
Entity testingResponse = new Entity("TestingResponse", 1000000L);
testingResponse.setProperty("name", "Only");
return testingResponse;
}
#ApiMethod(name = "echoname", path = "/echo/v1/echoname/{name}")
public Entity echoname(
#Named("name") #Nullable String name) {
Entity testingResponse = new Entity("TestingResponse", 1000000L);
testingResponse.setProperty("name", name);
return testingResponse;
}
#ApiMethod(name = "echoage", path = "/echo/v1/echoage/{name}/{age}")
public Entity echoage(
#Named("name") String name,
#Named("age") String age) {
Entity testingResponse = new Entity("TestingResponse", 1000000L);
testingResponse.setProperty("name", name);
testingResponse.setProperty("age", age);
return testingResponse;
}
}
pom.xml (partial only which I think are relevant here...)
<groupId>endpoints</groupId>
<artifactId>endpoints</artifactId>
<properties>
<endpoints.project.id>MYCLOUDRUNSERVICENAME-HASHCODE-uc.a.run.app</endpoints.project.id>
<appengine.maven.plugin.version>2.3.0</appengine.maven.plugin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.showDeprecation>true</maven.compiler.showDeprecation>
<endpoints.framework.version>2.2.1</endpoints.framework.version>
<endpoints.management.version>1.0.4</endpoints.management.version>
</properties>
<dependencies>...</dependencies>
<build>
<plugins>...</plugins>
</build>
appengine-web-.xml
<threadsafe>true</threadsafe>
<sessions-enabled>false</sessions-enabled>
<service>default</service> <!-- THIS IS USED TO UPLOAD TO A SPECIFIC SERVICE. REMOVE THIS FOR DEFAULT -->
<runtime>java8</runtime>
<system-properties>
<property name="java.util.logging.config.file"
value="WEB-INF/logging.properties" />
</system-properties>
<env-variables>
<env-var name="ENDPOINTS_SERVICE_NAME" value="${endpoints.project.id}" />
</env-variables>
web.xml
<servlet>
<servlet-name>EndpointsServlet</servlet-name>
<servlet-class>com.google.api.server.spi.EndpointsServlet</servlet-class>
<init-param>
<param-name>services</param-name>
<param-value>com.example.endpoints.Echo</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>EndpointsServlet</servlet-name>
<url-pattern>/_ah/api/*</url-pattern>
</servlet-mapping>
<filter>
<filter-name>endpoints-api-configuration</filter-name>
<filter-class>com.google.api.control.ServiceManagementConfigFilter</filter-class>
</filter>
<filter>
<filter-name>endpoints-api-controller</filter-name>
<filter-class>com.google.api.control.extensions.appengine.GoogleAppEngineControlFilter</filter-class>
<init-param>
<param-name>endpoints.projectId</param-name>
<param-value>${endpoints.project.id}</param-value>
</init-param>
<init-param>
<param-name>endpoints.serviceName</param-name>
<param-value>${endpoints.project.id}</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>endpoints-api-configuration</filter-name>
<servlet-name>EndpointsServlet</servlet-name>
</filter-mapping>
<filter-mapping>
<filter-name>endpoints-api-controller</filter-name>
<servlet-name>EndpointsServlet</servlet-name>
</filter-mapping>
deployendpoint.yaml
swagger: '2.0'
info:
title: MyEndPointTestApi771 API
description: Sample API on Cloud Endpoints with a Cloud Run, Cloud Function and App Engine with IAP backend
version: 1.0.0
host: MYCLOUDRUNSERVICENAME-HASHCODE-uc.a.run.app
basePath: /_ah/api
schemes:
- https
consumes:
- application/json
produces:
- application/json
x-google-backend:
address: https://MYPROJECTID.uc.r.appspot.com
jwt_audience: IAP_CREATED_WEBCLIENTID_FROM_CREDENTIALS
x-google-allow: all
paths:
/echo/v1/echoonly:
post:
summary: echoonly
operationId: EchoEchoonly
responses:
'200':
description: A successful response
schema:
$ref: "#/definitions/Entity"
security:
- google_id_token: []
/echo/v1/echoname/{name}:
post:
summary: echoname
operationId: EchoEchoname
parameters:
- in: path
name: name
required: true
type: string
responses:
'200':
description: A successful response
schema:
$ref: "#/definitions/Entity"
security:
- google_id_token: []
/echo/v1/echoage/{name}/{age}:
post:
summary: echoage
operationId: EchoEchoage
parameters:
- in: path
name: name
required: true
type: string
- in: path
name: age
required: true
type: string
responses:
'200':
description: A successful response
schema:
$ref: "#/definitions/Entity"
security:
- google_id_token: []
definitions:
_any:
type: "object"
Entity:
type: "object"
properties:
appId:
type: "string"
key:
$ref: "#/definitions/Key"
kind:
type: "string"
namespace:
type: "string"
parent:
$ref: "#/definitions/Key"
properties:
$ref: "#/definitions/Map_String_Object"
propertiesFrom:
$ref: "#/definitions/Entity"
Map_String_Object:
type: "object"
additionalProperties:
$ref: "#/definitions/_any"
JsonMap:
type: "object"
Key:
type: "object"
properties:
appId:
type: "string"
complete:
type: "boolean"
id:
type: "integer"
format: "int64"
kind:
type: "string"
name:
type: "string"
namespace:
type: "string"
parent:
$ref: "#/definitions/Key"
securityDefinitions:
api_key:
type: "apiKey"
name: "key"
in: "query"
google_id_token:
authorizationUrl: 'https://accounts.google.com/o/oauth2/v2/auth?client_id=IAP_CREATED_WEBCLIENTID_FROM_CREDENTIALS&response_type=code&scope=openid%20email&access_type=offline&redirect_uri=urn:ietf:wg:oauth:2.0:oob'
flow: "implicit"
type: "oauth2"
x-google-issuer: "https://accounts.google.com"
x-google-jwks_uri: "https://www.googleapis.com/oauth2/v3/certs"
x-google-audiences: "IAP_CREATED_WEBCLIENTID_FROM_CREDENTIALS"
Update
I could not figure this out and went with Spring #RestController which worked perfect, without having to worry about creating Endpoints API on Google Cloud Platform

Internal error during creation of App Engine via deployment manager

I am trying to create an App Engine service via Deployment Manager.
My deployment-manager.yaml file looks like below
imports:
- path: create-app-engine-std.py
resources:
- name: create-app-engine-std-app
type: create-app-engine-std.py
properties:
name: app-engine-std-app
appsId: projectId
zip:
sourceUrl: https://storage.googleapis.com/some-bucket/xyz.zip
filesCount: 2
version: v1
runtime: nodejs8
My create-app-engine-std.py look like below
def GenerateConfig(cxt):
deployment = {}
if cxt.properties['zip']:
deployment = {
'zip': {
'sourceUrl': cxt.properties['zip']['sourceUrl'],
'filesCount': cxt.properties['zip']['filesCount']
}
}
resources = [{
'type': 'gcp-types/appengine-v1:apps.services.versions',
'name': 'app-engine-std-app',
'properties': {
'servicesId': 'app-engine-std-test-app',
'appsId': cxt.properties['appsId'],
'deployment': deployment,
'runtime': cxt.properties['runtime'],
'threadsafe': True,
'id': cxt.properties['version']
}
}]
return {'resources': resources}
When I execute the deployment command I get following error
message: '{"ResourceType":"gcp-types/appengine-v1:apps.services.versions","ResourceErrorCode":"500","ResourceErrorMessage":"An
internal error occurred."}'
I tried using the apps.services.versions.create API but I always get following error although I am owner of the project
{
"error": {
"code": 403,
"message": "The caller does not have permission",
"status": "PERMISSION_DENIED"
}
}
Can someone guide me why I am getting the internal error and why can't I use the API. Thanks...

Creating a New SKU Via Stripe API from a Script in Gatsby React

I want to create a new SKU via the stripe API. But, it looks like the Stripe API doesn't support Gatsby: https://stripe.com/docs/api/skus/create?lang=node - the "closest" thing would be Node.js --- which isn't even close to Gatsby.
I've tried coping and pasting the Node.js version of the code but I believe it breaks the Gatsby compilation procedure because it's using Node.js syntax - which isn't allowed in my React/Gatsby syntax.
var stripe = require("stripe")("sk_secret_key");
stripe.skus.create({
product: '200',
attributes: {size: 'Medium', gender: 'Unisex'},
price: 1500,
currency: 'usd',
inventory: {type: 'finite', quantity: 500}
}, function(err, sku) {
// asynchronously called
});
This doesn't compile at all.
Is creating SKU's in Stripe just 100% incompatible with Gatsby? Or is there a better way to approach this?

Swagger YAML generated by camel not compatible with Swagger Editor and UI

I have the following Camel Rest config. Both my Request and response body are plain text.
<post uri="/swagger" produces="application/text" consumes="application/text"
type="String" outType="String">
<param name="body" type="body" description="Transaction to send" required="true" dataType="String"/>
<responseMessage message="OK" code="200" />
<route id="swaggerdemoRoute">
<transform><constant>success</constant></transform>
</route>
</post>
The Yaml generated by camel is not compatible with Swagger editor and UI.
/swagger/swagger:
post:
tags:
- "swagger"
operationId: "swagger_rest"
consumes:
- "application/text"
produces:
- "application/text"
parameters:
- in: "body"
name: "body"
description: "Transaction to send"
required: true
responses:
200:
description: "OK"
schema:
type: "string"
format: "String"
However, I can manually make it work by adding 2 lines after the "body" parameters:
- in: "body"
name: "body"
description: "Transaction to send"
required: true
schema:
type: string
Based on some input, I bumped Camel version to 2.20.2 and add dataType="String" in the "param" section. Still has the same problem. Additionally, an "operationId" is generated and Swagger complain its duplication.
How do I make it work from camel REST config?
Okay looked into this some more and yeah its a little bug. I have logged a ticket and work on a fix: https://issues.apache.org/jira/browse/CAMEL-12255

Camel CXF Component: Call ws with Json String body

I could not get along with the Camel CXF component. The problem is, th WS operation that I want to call has only a String parameter which is a JSON expression.
But , with every dataFormat (MESSAGE,POJO,PAYLOAD), it gives exception.
There are classes which are generated from wsdl2java by cxf itself and I am using them to call ws.
<cxf:cxfEndpoint id="wsEndpoint" address="http://www.wssss.com" serviceClass="aa.bb.cc.WebService" serviceName="sendMessage">
<cxf:properties>
<entry key="dataFormat" value="CXF_MESSAGE"/>
<entry key="defaultOperationName" value="sendMessage"/>
<entry key="relayHeaders" value="false"/>
<entry key="wrapped" value="true"/>
<entry key="loggingFeatureEnabled" value="true"/>
<entry key="synchronous" value="true"/>
<entry key="defaultOperationNamespace" value="http://com.asdad.ns"/>
</cxf:properties>
</cxf:cxfEndpoint>
and I am using this in:
camel:to uri="cxf:bean:wsEndpoint"/>
And generated service class is:
#WebResult(name = "response", targetNamespace = "")
#RequestWrapper(localName = "sendMessage", targetNamespace = "http://com.xxx.comet.ws.notification", className = "aaa.bbb.ccc.SendMessage")
#WebMethod
#ResponseWrapper(localName = "sendMessageResponse", targetNamespace = "http://com.xxx.comet.ws.notification", className = "aaa.bbb.ccc.SendMessageResponse")
public java.lang.String sendMessage(
#WebParam(name = "request", targetNamespace = "")
java.lang.String request
);
Any help will be appreciated
Thanks
EDIT: The problem is, exchange.in body could not be bound with the service method's parameter so request is empty. There is the problem in here
INFO: Outbound Message
---------------------------
ID: 1
Address: http://www.wssss.com
Encoding: UTF-8
Http-Method: POST
Content-Type: text/xml
Headers: {Accept=[*/*], breadcrumbId=[ID-TT08328507-61662-1416561287466-0-1], SOAPAction=[""]}
Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"/><soap:Body/></soap:Envelope>
--------------------------------------
Nov 21, 2014 4:45:04 AM org.apache.cxf.services.sendMessage.MessagePort.Message
INFO: Inbound Message
----------------------------
ID: 1
Response-Code: 500
Encoding: UTF-8
Content-Type: text/xml;charset=UTF-8
Headers: {connection=[close], Content-Length=[271], content-type=[text/xml;charset=UTF-8], Date=[Fri, 21 Nov 2014 09:15:04 GMT], Server=[Apache-Coyote/1.1]}
Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><soap:Fault><faultcode>soap:Server</faultcode><faultstring>No binding operation info while invoking unknown method with params unknown.</faultstring></soap:Fault></soap:Body></soap:Envelope>
--------------------------------------
org.apache.cxf.binding.soap.SoapFault: No binding operation info while invoking unknown method with params unknown.
at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.unmarshalFault(Soap11FaultInInterceptor.java:84)
at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(Soap11FaultInInterceptor.java:51)
at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(Soap11FaultInInterceptor.java:40)
The outbind message is an empty SOAP envelop.
Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"/><soap:Body/></soap:Envelope>
Did setup the invocation parameter rightly?

Resources