Swagger editor dictionary parameter definition - swagger-2.0

I'm struggling with how to define a dictionary type in swagger editor. One of the parameters to my POST method is called 'roles' and it's value is a dictionary where the key is the email address and the value is an integer.

Swagger supports associative arrays/hashmaps/dictionaries where keys are strings. A dictionary is defined by using an object schema with the additionalProperties keyword specifying the value type of key/value pairs. The key type is not mentioned because keys are always strings.
So a string-to-integer dictionary can be defined as:
definitions:
MyDictionary:
type: object
additionalProperties:
type: integer
By default, Swagger UI 3.x and Swagger Editor 3.x render dictionaries as containing properties named additionalProp*:
If you want a more meaningful example, add an example to your dictionary schema:
definitions:
MyDictionary:
type: object
additionalProperties:
type: integer
example:
apples: 5
oranges: 7

Related

AWS AppSync - Creating Resources for schema missing custom types and enums

I understand that enums are not standard type in Dynamo: https://forums.aws.amazon.com/thread.jspa?messageID=836386
However, what is the exact resolution here?
How are we supposed to appropriately represent relations with the generated code?
-- Am I missing something or is the generated code correct and we need to create some custom fields in the dynamo tables and then rewrite the queries?
Example:
type Competition {
id: ID!
name: String!
creator: UserProfile!
startDate: String!
endDate: String!
competitionType: CompetitionType!
competitors: [UserProfile]!
prize: Prize!
}
A competition is created by a user, has a type, a prize, and has competitors. When create resources for this table, the code is clearly missing any information that is derived out of the custom types or enums. Complex schemas will always have this type of structure, so I'm a bit confused on the outputted code and right direction from here.
extend type Mutation {
createCompetition(input: CreateCompetitionInput!): Competition
}
input CreateCompetitionInput {
id: ID!
name: String!
startDate: String!
endDate: String!
## Missing info
}
When AppSync generates the schema automatically it skips these as they are intended to be added manually with additional resolvers. You can define a new query that is attached to each of the custom or enum fields, but the data you are referencing will need to be stamped with something that is unique to the competition so that it can be queried on in relation to this type (as dynamoDB isn't a relational db).
When creating a new Competition you will need to update child fields with something unique to that competition. I.e. each UserProfile that needs to be tracked as a competitor gets stamped with this Competitions ID. Mutations for each of the custom fields need to be handled separately.
This article helped me solve this same question: https://keyholesoftware.com/2018/05/17/go-forth-and-appsync/.

How to update a Lookup field and a user field in SharePoint with Microsoft Graph?

I'm looking for a way how to update a lookup field and a user field with Microsoft graph ?
I can read the item, but I don't find a way to create or update this kind of field even if I put a correct ID value.
Nowadays it is supported to update lookup fields via Microsoft Graph API.
Lets say there is a field named Category, then depending whether lookup field is represented as single or multi valued, the following examples demonstrate how to set lookup field value.
for single-valued field:
Url: https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items/{item-id}/fields
Method: PATCH
Body: {
"CategoryLookupId": "1"
}
where
field name is provided in the following format: {field-name}LookupId
field value corresponds to lookup id and provided as a string
for multi-valued field
Url: https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items/{item-id}/fields
Method: PATCH
{
"CategoryLookupId#odata.type": "Collection(Edm.String)",
"CategoryLookupId":["1","2"]
}

Storing custom Type in SQLite .NET field

We are using SQLite.Net in a C# application and I want to define a property on one of the classes that gets stored on the db as having a custom type.
The type is essentially an Enum and a string, can be serialised to a string representation and I have overridden ToString
What is the correct way of getting this type in and out of a Field?
Thanks

creating enum and float data type in doctrine and symfony 2

I am using symfony 2 with doctrine. Doctrine does not seem to have enum data type.
My first question is how to set up enum data type so that when creating the actual tables from the entity, column having this enum data type is also reflected in the table structure.
Doctrine supports float data type but how to setup datatype as float(10,2). I tried following in my yaml meta data:
weight:
type: float
scale: 2
This did not work for me. I read the documentation and says it requires setLocale for scale to work. How do I fix this in symfony 2?

What is the difference between prependClientTransformer and appendClientTransformer in Symfony2 form?

What is the difference between prependClientTransformer and appendClientTransformer in Symfony2 form? When should I use prependClientTransformer, appendClientTransformer. Any examples?
What I've understood about this :
The FormType you're applying the DataTransformer to has a parent Type defined in getParent() method.
prependClientTransformer will apply passed DataTransformer BEFORE those ones that are applied from parent Type.
appendClientTransformer will apply passed DataTransformer AFTER those ones that are applied from parent Type.
As you see in the source these methods are used to control the calling sequence of the clientTransformers which are used for transform the field data. It is useful when you create custom field type.
For example you want to create a tag field type which will take comma separated values which will internally transformed to array of tags. You set its parent as text field type. You also created a transformer for tag type which transforms array to string or vice-versa. Now your tag type will have two clientTranformer, ValueToStringTransFormer and your transformer at last position. So when you bind data to a form or submit the form symfony will transform the client data to string and convert the transformed string then to array (as described here). And for reverse case it will transform the array to string and then string to client value (as defined here). Haven't found a use case for prependClientTransformer though :).

Resources