When i'm trying to mock external HTTP API with MockServer, mockserver returns java.lang.IllegalArgumentException
This is the test code:
new MockServerClient("localhost", 1080)
.when(request("/messages")
.withMethod("POST")
.withQueryStringParameters(
param("subject", "integration-test-subject")
)
).respond(response().withStatusCode(200));
This is the exception:
java.lang.IllegalArgumentException: Exception while parsing
[
{
"httpRequest":{
"method":"POST",
"path":"/messages",
"queryStringParameters":{
"subject":[
"integration-test-subject"
]
}
},
"httpResponse":{
"statusCode":200
},
"times":{
"remainingTimes":0,
"unlimited":true
},
"timeToLive":{
"unlimited":true
}
}
] for Expectation
And this is the Jackson exception:
com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of `java.lang.String` out of FIELD_NAME token
at
[
Source:(String)" {
"httpRequest":{
"method":"POST",
"path":"/messages",
"queryStringParameters":{
"subject":[
"integration-test-subject"
]
}
},
"httpResponse":{
"statusCode":200
},
"times":{
"remainingTimes":0,
"unlimited":true
},
"timeToLive":{
"unlimited":true
}
}
I'm trying to send application/x-www-form-urlencoded request with body
subject:integration-test-subject
When .withQueryStringParameters(param("subject", "integration-test-subject")) is not present in test, then it goes OK.
How to fix this?
This is an issue in GitHub with an explanation
https://github.com/jamesdbloom/mockserver/issues/451
you can just update to 5.4.1
the solution of this problem is to add to your project:
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.3</version>
</dependency>
im my project with Spring Boot 2 this solution worked fine.
Related
I'm following the micronaut doc for openapi at https://micronaut-projects.github.io/micronaut-openapi/latest/guide/
and the UI is not being generated, every time when I try to access /swagger, /swagger-ui I got this error:
{
"message": "Not Found",
"_links": {
"self": {
"href": "/swagger",
"templated": false
}
},
"_embedded": {
"errors": [
{
"message": "Page Not Found"
}
]
}
}
The dependencies are installed:
implementation("io.swagger.core.v3:swagger-annotations")
annotationProcessor("io.micronaut.openapi:micronaut-openapi:4.5.2")
The router on application.yml is defined:
micronaut:
application:
name: myapp
router:
static-resources:
default:
enabled: true
swagger:
enabled: true
paths: classpath:META-INF/swagger
mapping: /swagger/**
and the file openapi.properties on the root folder is created:
swagger-ui.enabled=true
micronaut.openapi.views.spec=apidoc.enabled=true,swagger-ui.enabled=true,swagger-ui.theme=flattop
micronaut.openapi.expand.api.version=v0.1
micronaut.openapi.expand.openapi.description=myapp
according to the docs a .yml file should be generated at;
For Kotlin build/tmp/kapt3/classes/main/META-INF/swagger/myapp-0.1.yml
On my controllers I have the Operation and ApiResponses annotation as well, but when I run the application the file yml is not being generated, how can I properly enable swagger on my micronaut project?
Code sample: https://github.com/rafa-acioly/micronaut
You defined only swagger in your application.yml. You should add also add a section for swagger-ui with a similar definition:
micronaut:
application:
name: openapitest
router:
static-resources:
swagger:
paths: classpath:META-INF/swagger
mapping: /swagger/**
swagger-ui:
paths: classpath:META-INF/swagger/views/swagger-ui
mapping: /swagger-ui/**
Also, I used the default openapi.properties file:
swagger-ui.enabled=true
redoc.enabled=false
rapidoc.enabled=false
rapidoc.bg-color=#14191f
rapidoc.text-color=#aec2e0
rapidoc.sort-endpoints-by=method
And did you try to clean and build your project with gradlew?
I create a sample repository on GitHub and you can check it.
=========UPDATE========
Ok, I've found what is incorrect! You are using annotation-processing :
annotationProcessor("io.micronaut.openapi:micronaut-openapi:4.5.2")
But if you are using Kotlin, you should use kapt - Kotlin Annotation Processing Tool. Here is a few articles - link1, link2.
So you should change to:
kapt("io.micronaut.openapi:micronaut-openapi:4.5.2")
I have a really weird problem. I've search already the whole web for the solution and found nothing.
I am not newbie in PHP.
I use Lumen in my application. To send the data I use Postman.
The problem is:
$request->file() and $request->allFiles() returns NULL.
But if I use PHP $_FILES then it shows all.
Route:
$router->post('/import/create', 'CalendarController#importCreate');
Controller:
public function importCreate(Request $request)
{
// Get uploaded CSV file
$files = $request->allFiles();
return response($files);
}
This is what I get back:
{
"files": [
{}
]
}
(empty json array)
But if I do like this:
return response($_FILES);
Then it works:
{
"files": {
"name": [
"logo.png"
],
"type": [
"image/png"
],
"tmp_name": [
"/tmp/phpjcjN4q"
],
"error": [
0
],
"size": [
7278
]
}
}
What we can exclude::
I use good Request import:
use Illuminate\Http\Request;
php.ini settings are OK:
The file I tried to upload has only 7KB, so its not the problem.
I use POST, and not PUT, so its not the problem.
Postman Request:
What I also noticed that $request->all() and $request->input() both returns also NULL, even if I post anything.
As I said I am not newbie in this, and I really appreciate your help.
Anyone got any clue?
Thanks in advance.
Ok, it has been fixed somehow. Don't know how, don't know when.
I updated composer dependencies with composer update but I'm not sure if that was the case.
I'm new to modding and I have been trying to add blocks to Minecraft 1.17.1 that I feel are missing. I've had problems before that I solved after a while but this one has had me stumped for a couple days now.
As you can see, my item block models are working just fine along with any cube_all block models. Cube_column models however, are not being registered.
Game Image
Here is my blockstates file along with their models. Maybe you can see the obvious mistake that I can't appear to find.
Blockstates
{
"variants": {
"axis=x": {
"model": "expansion:block/stone_pillar_horizontal",
"x": 90,
"y": 90
},
"axis=y": {
"model": "expansion:block/stone_pillar"
},
"axis=z": {
"model": "expansion:block/stone_pillar_horizontal",
"x": 90
}
}
}
Model
{
"parent": "minecraft:block/cube_column",
"textures": {
"end": "expansion:blocks/stone_pillar_top",
"side": "expansion:blocks/stone_pillar"
}
}
Horizontal Model
{
"parent": "minecraft:block/cube_column_horizontal",
"textures": {
"end": "expansion:blocks/stone_pillar_top",
"side": "expansion:blocks/stone_pillar"
}
}
Here is also the terminal message I receive when launching the mod. As you can see, the program for some reason takes issue with 'axis' and claims that my models are missing.
[Worker-Main-11/WARN] (Minecraft) Exception loading blockstate definition: 'expansion:blockstates/stone_pillar.json' in resourcepack: 'Expansion' for variant: 'axis=z': Unknown blockstate property: 'axis'
[Worker-Main-11/WARN] (Minecraft) Exception loading blockstate definition: 'expansion:blockstates/stone_pillar.json' in resourcepack: 'Expansion' for variant: 'axis=x': Unknown blockstate property: 'axis'
[Worker-Main-11/WARN] (Minecraft) Exception loading blockstate definition: 'expansion:blockstates/stone_pillar.json' in resourcepack: 'Expansion' for variant: 'axis=y': Unknown blockstate property: 'axis'
[Worker-Main-11/WARN] (Minecraft) Exception loading blockstate definition: 'expansion:blockstates/stone_pillar.json' missing model for variant: 'expansion:stone_pillar#'
I have double and triple checked that all of my files are where they should be, that there are no simple spelling mistakes and that nothing was left untied. IntelliJ also says that all my work has no flaws that it can tell. Please help me because I can't find it anywhere else :(
Getting this error after upgrading to RN 62.2
Configuration error:
Could not locate module ./images/ticketsMessageIcon.png mapped as:
RelativeImageStub.
Please check your configuration for these entries:
{
"moduleNameMapper": {
"/^[#.\/a-zA-Z0-9$_-]+\.(png|gif)$/": "RelativeImageStub"
},
"resolver": null
}
The moduleNameMapper didn't change and here is what it looks like
"moduleNameMapper": {
"^image![a-zA-Z0-9$_-]+$": "GlobalImageStub",
"^[#./a-zA-Z0-9$_-]+\\.(png|gif)$": "RelativeImageStub",
"^globalize$": "<rootDir>/node_modules/globalize/dist/node-main.js"
},
I am not sure , how to use elasticsearch API avaialble in below link in angular application.
https://www.elastic.co/guide/en/elasticsearch/reference/current/search.html
I have gone through the below sit for using elasticsearch services.But for other functionality like multi field search, conditional search, pagination with first and last pages, i didnt get any idea how to proceed.
http://javasampleapproach.com/frontend/angular/angular-4-elasticsearch-example-quick-start-how-to-add-elasticsearch-js#comment-3537
Please kindly share any links or guide me using elastic search in angular cli (angular 2) application.
There is a javascript client available too.
https://www.npmjs.com/package/elasticsearch
npm install elasticsearch --save
Its typings are available from definitelyTypes
npm install #types/elasticsearch --save
Then you can directly use in your angular application
Example :
To create ElasticSearch client
...
import { Client } from 'elasticsearch';
...
this.esClient = new Client({
host: 'elastic-url'
});
...
everything is there in the official client For features such as pagination, conditional search you have to constuct your query properly before passing.
Example Query:
{
"query": {
"bool": {
"should": [
{
"term": {
"param2": "HUMAN"
}
},{
"match": {
"param1": "param1"
}
}
]
}
}
Example Usage:
client.search({
index: 'masterindex',
body: {
"size":0,
"query": esQuery,
"aggs": aggOBj
}
},(error, response)=> {})