What is the best way to get the .cs file from a given .proto file with protobuf.net - json.net

After several trial with the protobuf.net online generator, I doubt of the way y use to get the more relevant .cs file from an .proto file.
The Input proto file is the sparkplub_b file from link below:
https://github.com/Cirrus-Link/Sparkplug/blob/master/sparkplug_b/sparkplug_b.proto
In Sparkplug documentation the Datatype enums have the string form 'Uint64', and in the result .cs file we have ‘LongValue’.
(I have also to do some changes in the .cs file to be able to use enums with the 'DataType' in the JSON serialization of the object instance)
Thank you.
"Timestamp": 1538568112852,
"Metrics": [
{
"Name": "bdSeq",
"Timestamp": 1538568112852,
"Datatype": 4,
"IsNull": false,
"Metadata": null,
"Properties": null,
"LongValue": 0,
"ValueCase": 11
}
],
"Seq": 18446744073709551615
}

Sorry for delay, I was taking some time off. I'm the protobuf-net author.
What is the best way to get the .cs file from a given .proto file with protobuf.net
Ultimately, for protobuf-net specifically: protogen - which is what https://protogen.marcgravell.com/ uses (I assume that's what you were talking about when you say "with the protobuf.net online generator")
In Sparkplug documentation the Datatype enums have the string form 'Uint64', and in the result .cs file we have ‘LongValue’.
I assume that is coming from:
uint64 long_value = 4;
If the concern is the naming (LongValue vs long_value), then note that protobuf-net has options to allow more control over this; LongValue is just the default convention.
However: this isn't an enum - there is no enum in sparkplug_b.proto. If you can be more specific about what you want to get as the generated code (and ideally, why), I can almost certainly help more.
(edit: there is an enum optionally generated from the oneof)

Related

Using r googledrive package to create custom property

According to the documentation for drive_mkdir() in the googledrive package, "Named parameters to pass along to the Drive API. Has the tidy dots semantics that come from using rlang::list2(). You can affect the metadata of the target file by specifying properties of the Files resource via .... Read the "Request body" section of the Drive API docs for the associated endpoint to learn about relevant parameters." In the Google Drive API, it lists adding custom properties as, "Custom file properties are key/value pairs used to store custom metadata for a file, such as tags, IDs from other data stores, information shared between workflow applications, and so on.
To add properties visible to all apps, use the properties field of files resource."
In the Google API Files Page, it lists it as
"properties": {
(key): string}
I've tried a number of different ways to pass a value, but nothing seems to work. Does anyone have an example of adding a custom property while creating a folder?
Here is one example I've tried that does not work:
GDriveTarget <- "https://drive.google.com/drive/u/1/folders/'etc'"
drID <- drive_get(GDriveTarget, verbose = TRUE)
gProps <-list2(properties = c("Region","Far Northeast"))
curFolder <- drive_mkdir(name="School Folders",
path=GDriveTarget,
gProps)
this results in:
Error: These parameters are unknown:
Backtrace:
googledrive::drive_mkdir(...)
googledrive::drive_create(...)
googledrive::request_generate(...)
gargle::request_develop(endpoint = ept, params = params)
gargle:::check_params(params, endpoint$parameters)
gargle:::stop_bad_params(unknown, reason = "unknown")
Removing "gProps" creates the desired folder, so I have the proper rights. I'm just unsure how to pass the parameters Google is expecting. When I use the "try this API" tool on Google Developer, what it is expecting is:
{
"properties": {
"Region": "Far Northeast"
}
}

How to define the default grammar for new file extensions

I'm opening files in Atom with a new file extension, a file extension that is not recognized by any of the existing grammars (i.e. Plain Test, C, C#, etc.). How can I associate my new file extension with one of the already-available grammars?
Success is being able to open a file with my new file extension and have Atom default to my chosen grammar automatically.
I tried the suggestion but Atom bounced it back at me:
customFileTypes:
"source.fs": [
"*.seedsource"
]
For personal use, you can register a custom file type in the Atom config file (config.cson by default).
Here's a minimal example of what config.cson might look like. Make sure to insert the customFileTypes part at the correct indentation, since CSON files are indentation-sensitive.
"*":
core:
customFileTypes:
"source.c": [
"*.custom-extension"
]
If you want to share this configuration with other users, it's probably better to create a package that contains a grammar file (e.g. grammars/custom.cson):
fileTypes: [
"custom-extension"
]
patterns: [
{
include: "source.c"
}
]
scopeName: "source.c.custom"
In both cases, example.custom-extension would be opened with C syntax highlighting.

Using parameters in Azure Service Bus Subscription SqlFilter expression

I am using an ARM template to try and deploy a subscription to an Azure Service Bus Topic which filters messages based on the To system property. I would like to pull the value for the filter from an ARM template parameter, but I can't seem to get the template to resolve the param in the SqlExpression.
Below is the template I have been messing around with. I thought I could maybe just toggle the requiresPreprocessing switch to get it to resolve the param on deployment, but no dice. I also played with trying to escape it using double square brackets or colons as shown in the link below
https://learn.microsoft.com/en-us/azure/service-bus-messaging/service-bus-messaging-sql-filter#propertyname
{
"apiVersion": "2017-04-01",
"name": "[concat(parameters('mynamespace'), '/', parameters('topic'), '/', parameters('myVariable'),'/direct')]",
"type": "Microsoft.ServiceBus/namespaces/topics/subscriptions/rules",
"dependsOn": [
"[resourceId('Microsoft.ServiceBus/namespaces', parameters('mynamespace'))]",
"[resourceId('Microsoft.ServiceBus/namespaces/topics', parameters('mynamespace'), parameters('topic'))]",
"[resourceId('Microsoft.ServiceBus/namespaces/topics/subscriptions', parameters('mynamespace'), parameters('topic'), parameters('myVariable'))]"
],
"properties": {
"filterType": "SqlFilter",
"sqlFilter": {
"sqlExpression": "sys.To=[parameters('myVariable')] OR sys.To IS NULL",
"requiresPreprocessing": true
}
}
What I am getting is the string exactly as it is displayed in the sqlExpression, but I would like to get the value that the variable resolves to in a single quoted string.
This topic subscription rules may only get static values. Maybe you can try with a static value instead of [parameters('myVariable')]. This problem might because of giving dynamic value to the property sys.To.
You could use: "[concat('sys.To=',[parameters('myVariable')],' OR sys.To IS NULL')]".
You cannot use inline expressions in an ARM template I think, therefor you should make the whole thing an expression and in this case use concat to glue the parts together.
Hint: including single quotes is difficult, so a variable like this might come in handy:
"SQ": "'"

Invalid schema for REST JSON CreatePassengerNameRecord response

I am trying to test the integration for the Sabre CreatePassengerNameRecord rest API. As the first step, I tried downloading the JSON schemas for the Request and Response and tried to generate the POJOs using jsonschema2pojo. But it looks like the schema files are all pointing to dependent references using a URL http://services.sabre.com which is non existing. Hence the POJO generation is getting failed. This is happening for both the request and response. I was able to fix the request schema by changing the URL for XMLSchemaTypes.json dependency to provided URL link in documentation, but the response has a reference which is not specified anywhere (Please check the Response schema section of question ).
API Link: https://developer.sabre.com/docs/rest_apis/air/book/create_passenger_name_record/
Response Schema:
In the response, there is a reference to http://services.sabre.com/STL_Payload/v02_02 which is not existing.
File : http://files.developer.sabre.com/doc/providerdoc/STPS/create_passenger_name_record/v200/CreatePassengerNameRecord2.0.0RS.json
....
"CreatePassengerNameRecordRS" : {
"type" : "object",
"title" : "CreatePassengerNameRecordRS",
"properties" : {
"version" : {
"type" : "string",
"minLength" : 1,
"maxLength" : 255
},
"ApplicationResults" : {
"$ref" : "http://services.sabre.com/STL_Payload/v02_02#/definitions/ApplicationResults"
....
It would be great it you could provide the latest file for the STL_Payload or update the documentation to the latest working version.
The missing files were added to the documentation page.
This should allow you to move forward.
The id-s are still used as tags and not as absolute resource pointers so you still need to play with it they way you described to make the auto-generation working out of the box.
We will consider your request to convert them to resource pointers in the future.
Just one more hint: if you are using Java-API version of jsonschema2pojo please use this for config:
GenerationConfig config = new DefaultGenerationConfig() {
public String getRefFragmentPathDelimiters() {
return "#/";
}
};
You need it because the default path delimiters in jsonschema2pojo are "#/." and the "." does not work with some of the types declared in the schema like Text.Long
+1 Sabre please make JSON schema available on http://services.sabre.com as it is problematic when generating models using Quicktype. Types are not being resolved correctly.

AlpacaJS - How to access file uploaded in File Field in Handlebars

I have a form with the following super basic file field:
Schema-
"file_upload": {
"type": "string"
}
Options-
"file_upload": {
"type": "file"
}
I want to access the file uploaded somehow, but particularly through Handlebars.js.
A regular field, say "file_checkbox" can be rendered using {{file_checkbox}} in handlebars but I can not figure out how to access the file.
Using basic javascript (document.getElementById('fieldId').files), I can see that the file has uploaded as anticipated.
But, trying to get the value of the Alpaca Form ($.alpaca($("#formDiv")).getValue()) yields the data from the regular fields (i.e. file_checkbox) and nothing from the file field.
When I submit the alpaca form all of the other data is properly saved, but again nothing from the file field (not even the name of the field with an empty/nil value)!
I've spent many hours searching and haven't found anything on the Alpaca website, Github Issues, or stack overflow! This is my first question so please let me know if there is any additional information I can provide.
Thank you!
That's normal with Alpaca, there will be no data for your file input set in your form data object, you should use the function selectionHandler to set the file(s) selected (you can use either File or Base64 data) to your form data like this :
"file-upload": {
"type": "file",
"selectionHandler": function(files, data) {
// files for multiple or use files[0] to get only one file
// and if you want to use base64 data you could use data
this.data = files;
}
}
And here's a fiddle for that.

Resources