SignalR HubConnection.On<>() ambiguous error - signalr

CS0121: The call is ambiguous between the following methods or properties: 'HubConnectionExtensions.On(
HubConnection, string, Action)' and 'HubConnectionExtensions.On(HubConnection, string, Func<T1, Task>)'
Connection.On<ViewAcknowledgementRequestSpecifier>("ReceiveAcknowledgementRequest", ReceiveAcknowledgementRequest);
Connection.On<ViewDelayRequestSpecifier>("ReceiveDelayRequest", ReceiveDelayRequest);
Connection.On<InfoRequestSpecifier>("ReceiveInfoRequest", ReceiveInfoRequest);

Related

Structural error property type should be equal to one of the allowed values allowedValues: string, number, boolean, integer, array in Swagger editor

I'm using springfox 2.9.2 and want test my swagger JSON as YAML in https://editor.swagger.io/
I have property with #ApiParam annotation type: object
#ApiParam(value = "metadata file")
protected Object metadataFile;
but when I test my generated json on swagger editor I got this error:
Structural error at ---.parameters.5.type should be equal to one of
the allowed values allowedValues: string, number, boolean, integer,
array Jump to line ---
there is way to allowed property type object in this section?
the section that trigger the problem
paths:
:
post:
parameters:
name: metadataFile
in: query
description: ...
required: false
type: object
Swagger documentation (go to the bottom of the page): https://swagger.io/docs/specification/2-0/describing-parameters/
"Can I have an object as a query parameter?
This is possible in OpenAPI 3.0, but not in 2.0."

How to read a value in Dynamic object obtained from JsonConvert.DeserializeObject

I am using httpClient to an API endpoint. There are a couple of possible JSON results I could get back depending on if the call if successful or not.
So I want to use a dynamic or ExpandoObject to DeserializeObject the results to.
However, I can't seem to be able to actual get anything from the object after Deserializing. I keep getting `
error CS1061: 'object' does not contain a definition for 'success' and no accessible extension method 'success' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)'
Here is a simplified example:
dynamic stuff = JsonConvert.DeserializeObject<ExpandoObject>("{ 'Name': 'Jon Smith', 'Address': { 'City': 'New York', 'State': 'NY' }, 'Age': 42 }");
When I try to access name like this stuff.name I get the following error:
error CS1061: 'object' does not contain a definition for 'name' and no accessible extension method 'name' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)
? stuff["name"]
error CS0021: Cannot apply indexing with [] to an expression of type 'object'
And yet the data is in there somewhere:
If I Deserialize like this I get the exact same result:
dynamic stuff = JsonConvert.DeserializeObject("{ 'Name': 'Jon Smith', 'Address': { 'City': 'New York', 'State': 'NY' }, 'Age': 42 }");
It was inferred in another post that it may have something to do with this being in an async function, but no real solution. I am running .Net core 3.1 from within an Azure function.
So how do I refer to the object to get a value out?

Use a reference to the same object inside an object

I'm trying to do something like this:
User:
type: "object"
properties:
id:
type: "integer"
format: "int64"
name:
type: "string"
manager:
$ref: "/definitions/User"
Editor does not throw an exception, but the code generated according to this schema does not work at all.
I generated python-flask server, and on launch, it throws:
ImportError: cannot import name 'User'
Looking through the code I found that 'User' class uses 'User' keyword in __init__ and inside the class.
Also there was the import: from swagger_server.models.user import User
Does python-flask generator know how to implement references like this?

Symfony service container injecting string not object

I'm trying to inject an object into one of my services, as well as another service. The second argument is just an object, however when declaring it in the services.yml file, I receive an exception staying that its expecting an object, but a string was given.
services.yml
parameters:
app.my_class.class: AppBundle\MyClass
app.object_to_inject.class: AppBundle\InjectObject
services:
app.my_service:
class: %app.my_class.class%
arguments: [#app.another_service, %app.object_to_inject.class%]
Which results in:
Catchable Fatal Error: Argument 2 passed to
AppBundle\MyClass::__construct() must be an instance
of AppBundle\InjectObject, string given
I've tried quoting, unquoting and using new lines instead of square brackets:
arguments
- #app.another_service
- %app.object_to_inject.class%
Parameters are just strings, so you you trying to inject the string of your class name, not the actual class.
You need to define AppBundle\InjectObject as a service, then inject that.
Example:
parameters:
app.my_class.class: AppBundle\MyClass
app.object_to_inject.class: AppBundle\InjectObject
services:
app.my_object:
class: "%app.object_to_inject.class%"
app.my_service:
class: %app.my_class.class%
arguments: [#app.another_service, #app.my_object]

Symfony2 passing associative array as argument in service definition issue

I am trying to pass an associative array as argument to a service definition (Solarium, to be precise). However, I get the following error:
"Catchable Fatal Error: Argument 1 passed to Symfony\Component\DependencyInjection\Definition::setArguments() must be of the type array, string given, "
My services.yml reads as follows:
parameters:
mynamespace.api.solrclient.config:
endpoint:
solrserver:
host: "search.mysite.com"
port: "80"
path: "/solr/"
services:
mynamespace.api.solrclient:
class: Solarium\Client
arguments: "%mynamespace.api.solrclient.config%"
Is there anything obviously wrong with the way I have defined the parameter array?
arguments must be an array, try:
services:
mynamespace.api.solrclient:
class: Solarium\Client
arguments: [%mynamespace.api.solrclient.config%]

Resources