I need to get data from servlet when I pass schema like below.
attrServlet is servlet call.
{
"id": "../test#",
"$schema": "../schema#",
"title": "Test",
"type": "object",
"format":"grid",
"required": [
"/"
],
"properties": {
"/":
{
"title":"value",
"$ref": "http://00.00.00.00:8080/Test/attrServlet/#"
}
}
}
In the place of $ref, I need servlet data. My data coming through servlet into browser but on front end it's not reflecting. Any idea?
Related
I am very new to hapi FHIR, I am trying to encode the request in following format.
CoverageEligibilityRequest coverageEligibilityRequest = new CoverageEligibilityRequest();
Patient patient = new Patient().addIdentifier(new Identifier().setType(getPatientIdentifierCodeableConcept()).setSystem("http://www.abc.xyz").setValue("123"));
coverageEligibilityRequest.setPatient(new Reference(patient));
Above code is java snippet for populating the patient in CoverageEligibilityRequest.
{
"resourceType": "Bundle",
"type": "batch",
"entry": [ {
"resource": {
"resourceType": "CoverageEligibilityRequest",
"id": "7890",
"contained": [ {
"resourceType": "Patient",
"id": "1",
"identifier": [ {
"type": {
"coding": [ {
...
...
}
But I want the request should be of following format
{
"resourceType": "Bundle",
"type": "batch",
"entry": [ {
"resource": {
"resourceType": "CoverageEligibilityRequest",
"id": "7890",
"patient": {
"type": "Patient",
"identifier": {
"type": {
"coding": [ {
...
...
} ]
},
where I want to omit contained with actual string?
FHIR doesn't generally let you express an entire graph of objects as a single resource, so if you're trying to send a Patient resource as part of a CoverageEligibilityRequest resource, the only way you can do that is by setting the patient in the contained field. The CoverageEligibilityResource.patient field is defined as a Reference type and so can only contain the data allowed by a Reference data type and not arbitrary data.
It seems like what you actually want to do is to add a Patient to the HAPI FHIR server and a CoverageEligibilityRequest resource that references the patient. The right way to do this in FHIR is to construct a single batch or transaction bundle containing both of the resources. Basically, you want to construct a Bundle that looks something like this:
{
"resourceType": "Bundle",
"type": "batch",
"entry": [ {
"resource": {
"resourceType": "Patient",
"id": "1",
"identifier": [ {
"type": {
"coding": [ {
...
}
}, {
"resource": {
"resourceType": "CoverageEligibilityRequest",
"id": "7890",
"patient": "Patient/1",
...
The easiest way to construct something similar in HAPI FHIR would be to use a transaction bundle like this:
IGenericClient client = ...
CoverageEligibilityRequest coverageEligibilityRequest = new CoverageEligibilityRequest();
Patient patient = new Patient().addIdentifier(new Identifier().setType(getPatientIdentifierCodeableConcept()).setSystem("http://www.abc.xyz").setValue("123"));
coverageEligibilityRequest.setPatient(new Reference(patient));
client.transaction().withResources(patient, coverageEligibilityRequest);
I am trying to create one mapping.json under the mappings folder with multiple stubs as below. But I am facing the following error
Wiremock: v2.5.1 (standalone)
Mapping.json file looks,
[
{
"scenarioName": "Savings account Stub",
"request": {
"url": "/ws/*****",
"method": "POST",
"bodyPatterns" : [{
"contains" : "AccountRequest"
}
]
},
"response": {
"status": 200,
"bodyFileName": "******"
}
},
{
"scenarioName": "Current account Stub",
"request": {
"method": "POST",
"url": "/ws/*****",
"bodyPatterns": [
{
"contains": "AccountListRequest"
}
]
},
"response": {
"status": 200,
"bodyFileName": "******"
}
}]
Error:
Exception in thread "main" wiremock.com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of com.github.tomakehurst.wiremock.stubbing.StubMapping out of START_ARRAY token
Is there any possibility to create multiple stubs for the same URL in single mapping file? Can anyone tell me what is the exact issue?
Looking at the stubbing documentation, I think you want your mappings.json to look like...
{
"mappings": [
{
"scenarioName": "foo",
"request": {},
"response": {}
}, {
"request": {}
}
],
"importOptions": {
"duplicatePolicy": "IGNORE",
"deleteAllNotInImport": true
}
}
You'd then want to make a POST request to /__admin/mappings/import with your mappings.json as the request body. The reason for this is that I believe multiple mappings in a single file are only supported via the import option.
In my play framework application, I have registered APIs in route file as:
POST /api/rmt-create-request controllers.Api.CreateRMTRequestForm
On action of controller, I am using following code to access formData submitted with form submit as :
public Result CreateRMTRequestForm()
{
Map<String, String[]> params = request().body().asMultipartFormData().asFormUrlEncoded();
Its working fine as API when I submit the form with forntend application.
I am trying to create APIs documentation with swagger.ui in which within swagger.json file I have written following JSON data.
"paths": {"/api/rmt-create-request": {
"post": {
"tags": [
"RMT APIs"
],
"description" : "Return newly created request data",
"operationId": "create-new-rmt-request",
"consumes": ["application/x-www-form-urlencoded"],
"parameters": [
{
"name": "rootNodeName",
"in": "formData",
"description": "Root node class name for item",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/rmt-request-data"
}
}
}
},
"default": {
"$ref": "#/components/responses/default"
}
}
}
},
While inspecting RequestHeader data, its not showing content-Type property with value 'multipart/form-data' as well as formData are not attached, which makes controller to throw null exception.
Can anyone help whats missing in swagger.json file ?
You are mixing OpenAPI 2.0 and 3.0 syntax.
In OpenAPI 3.0, request body (including form data) is defined using the requestBody keyword instead of in: formData parameters.
Also, OAS3 does not use consumes. The media types consumed by the operation are specified inside the requestBody.
"paths": {
"/api/rmt-create-request": {
"post": {
"tags": [
"RMT APIs"
],
"description": "Return newly created request data",
"operationId": "create-new-rmt-request",
"requestBody": {
"content": {
"multipart/form-data": { // or "application/x-www-form-urlencoded" - depending on what you need
"schema": {
"type": "object",
"properties": {
"rootNodeName": {
"type": "string",
"description": "Root node class name for item"
}
}
}
}
}
}
}
}
}
More information: Describing Request Body
I am using katharsis with spring boot.
I want to change the 'id' key in json response with my table PK column name, following is the katharsis response
{
"type": "table-name",
"id": "A",
"attributes": {
"description": "AAA"
},
"relationships": {
},
"links": {
"self": "http://localhost/table-name/A"
}
}
I want to change the above "id": "A" with "coulmnName":"A".
Answer on katharsis github repository
https://github.com/katharsis-project/katharsis-core/issues/203
I need to send a HTTP Post to a REST API with the following complex type as parameters. I looked at the documentation of jersey and it helps only to send a key value pair. How can i send a HTTP Post request with the below parameters using jersey.
{
"key": "example key",
"message": {
"html": "<p>Example HTML content</p>",
"text": "Example text content",
"subject": "example subject",
"from_email": "message.from_email#example.com",
"from_name": "Example Name",
"to": [
{
"email": "recipient.email#example.com",
"name": "Recipient Name"
}
],
"headers": {
"Reply-To": "message.reply#example.com"
},
"important": false,
"track_opens": null,
"track_clicks": null,
"auto_text": null,
"auto_html": null,
"inline_css": null,
"url_strip_qs": null,
"preserve_recipients": null,
"view_content_link": null,
"bcc_address": "message.bcc_address#example.com",
"tracking_domain": null,
"signing_domain": null,
"return_path_domain": null,
"merge": true,
"global_merge_vars": [
{
"name": "merge1",
"content": "merge1 content"
}
],
"merge_vars": [
{
"rcpt": "recipient.email#example.com",
"vars": [
{
"name": "merge2",
"content": "merge2 content"
}
]
}
],
"tags": [
"password-resets"
],
"subaccount": "customer-123",
"google_analytics_domains": [
"example.com"
],
"google_analytics_campaign": "message.from_email#example.com",
"metadata": {
"website": "www.example.com"
},
"recipient_metadata": [
{
"rcpt": "recipient.email#example.com",
"values": {
"user_id": 123456
}
}
],
"attachments": [
{
"type": "text/plain",
"name": "myfile.txt",
"content": "ZXhhbXBsZSBmaWxl"
}
],
"images": [
{
"type": "image/png",
"name": "IMAGECID",
"content": "ZXhhbXBsZSBmaWxl"
}
]
},
"async": false,
"ip_pool": "Main Pool",
"send_at": "example send_at"
}
I looked at the other questions of sending HTTP Post using Jersey and all I could find was a way to only send a key\value pairs as parameters and not complex string types like above.
You should look at JAXB, it allows you to "automatically" build "complex parameters" out of "objects". Basically the procedure would be to define a class that represents the data structure you present as request message the REST API resource accepts, then populate it with the data your want to POST and send it. In this question you can find more details on how to exactly do that: Can jersey clients POST a JAXB object to the server using JSON?