Swagger-Swashbuckle include xmlcomments from dependent dlls - swagger

I need to document an asp.net core web api and I m using swagger and swashbuckle.
I have looked around and I have found this link but it's old and does not work
https://github.com/domaindrivendev/Swashbuckle/issues/93
Can somebody show/point me how i can include xml comments from another dll?
thanks

There are two versions of swashbuckle:
https://github.com/domaindrivendev/Swashbuckle
https://github.com/domaindrivendev/Swashbuckle.AspNetCore
If the tags on this question are correct, your link is not to the version you are using, but still the solution offered should give you a good idea what you need to do.
You can include as many xml comments as you want with IncludeXmlComments that is still available on Swashbuckle.AspNetCore, see here:
Swashbuckle.AspNetCore.SwaggerGen/Application/SwaggerGenOptions.cs#L259
First you need to make sure that the xml comments you need are making it to the server as part of your deployment, otherwise Swashbuckle will not show what it is not there...
A solution could be to recursively loop looking for XML files and add them using the IncludeXmlComments, something like this:
public void IncludeAllXmlComments(string folder)
{
if (!string.IsNullOrEmpty(folder))
{
foreach (var name in Directory.GetFiles(folder, "*.XML", SearchOption.AllDirectories))
{
IncludeXmlComments(filePath: name);
}
}
}
This sample code is just to give you an idea, not for copy/pasta

Related

dart mdv databinding does not update on change

I am trying to get databinding to work in dart. Basically im doing the same as in this video. Using pseudo code it looks like this:
mdv.init();
var p = new Person('john');
query('#someId').model = p;
In the html file i also have a template which works correctly. For now i am only trying to get one way databinding to work and although the template is correctly initialized, subsequent changes to the variable p are not visible in the template. I tried to trigger an update like this
node.model = null;
node.model = p;
This does not trigger an update however. But if i'm using a delay it does work:
node.model = null;
new Timer(new Duration(milliseconds:20),(){
node.model = p;
});
So i have a couple of questions about this:
Why does a change in the variable not reflect a change in the template ?
Is the template not supposed to update the way i'm doing it? Or is mdv/polymer not working the way it is intended?
Is it possible manually trigger an update of the template?
Would it be possible to easily convert one-way to two-way databinding (i.e. by making the Person class in the psuedocode observable or something)?
PS i searched and tried several things before posting here. I found a topic in which a custom polymer element is created, which seems more of an hassle then i would like it to be. I also tried the fancy-syntax lib (this did't improve it) and databinder (compile error). I also read a couple of pages about polymer, but i'm not sure what is relevant to dart and has not been deprecated (or 'stale' as the warning above the page mentions).
You need one of the following packages, to update bindings automatically on change.
mdv_observe
observe
documentation (Observables)
I would still recommend you to just add "polymer" as a dependency (remove mdv) to your pubspec.yaml. This way you won't have to handle version issues and you would have a guarantee of a "confirmed" set of packages working together.

How to implement multilingualism in SPA

I'm currently struggling with the problem of multilingualism in an SPA.
I've come up with several solutions, like building a wrapper for the resources resx files, or saving all labels in the database, but I am wondering if any of you have found some solution which automates these steps.
Are there any practices which are specific for this problem?
For a reasonable amount of literals, I suggest to save the resources in the DB or in a .RESX file in the server. When the user logs in or you detect the language that will be used, the literals are requested by the application and saved either in a collection of your translation module or in the LocalStorage of the browser (this could be a good approach for large data).
Then this module could have some methods to retrieve the messages, probably passing a key.
Using this solution you could inject this module in the viewmodels that need to show translated literals and acces them through the view:
<p data-bind="text: resourceManager.get('M01')"></a>
For large applications that would require huge localization data to be transfered, maybe some kind of modularity could be applied and only load the resources really needed for each module/section.
I don't think making recurrent requests to the server to get the translated literals is a good practise. SPA's should provide a good user experience and loading the translated literals from the server could be a blocking issue. Text is not like an image, you can render a page without all the images loaded, imagine rendering a page without the text :o
Anyway, I think the best solution would be to keep the server as repository and create a custom JS module that takes care to get data in one or multiple loads and is able to store it somewhere in the client.
I've solved my own problem, using a custom binding and i18next.
First, I've implemented i18next for translation of my labels/buttons and other resources.
Secondly, I've added a custom Knockout bindingHandler:
ko.bindingHandlers.i18n = {
init: function (element, valueAccessor) {
var translateKey = valueAccessor();
ko.utils.setTextContent(element, $.t(translateKey));
}
};
Finally you can add the following code to your views:
<span data-bind="i18n : 'buttons.cancel'"></span>
This will automatically get the correct resource, and Knockout will handle the bindings.
Hopefully this will help others struggling with the same problem.

MVC 4 VB Additional view data

Trying to find help for this problem has taken me to a whole new one: complete lack of ressources, books and samples vor MVC 4 in VB.NET. I am having to choose between learn by experience (and the associated feeling of banging your head against a wall) or give it up and move to C# alltogether.
No company should ship a product if they are not willing to give it the same support as its sibling pruduct. They should drop VB for MVC completely or give us the means to learn it.
With that out of the way, here's my question. This line:
#Html.EditorFor(Function(x) x.UsersData(temp).Roles(Role))
Is a nice line of code. Works wonders. But How can I add a class to it, so I can change the style on my css files?
Well, it seems that this should do the trick:
#Html.EditorFor(Function(x) x.UsersData(temp).Roles(Role), New With {.class = "users-manage-check-box"})
But guess what, it doesn't. Ever. The result is the same.
What is wrong and how can I fix it?
And to be completely honest, I did come up with a solution. One that makes me feel dirty.
Looking at the output from that code, i see that the boxes classes are "check-box".
So what I've been doing is this:
#html.Raw(Html.EditorFor(Function(x) x.UsersData(temp).Roles(Role), New With {.class = "users-manage-textbox"}).ToHtmlString.Replace("check-box", "user-manage-checkbox"))
This feels wrong. So wrong. And not only is it a sad piece of code, it introduces security risks, which I'll have to fix before my solution is out of the development phase.
Any clues on why the additional view data is not working as it should? Am I getting something wrong? Am I asking too much?
Thanks a lot!
I don't think EditorFor allows that. So you need to create a custom editor template yourself.
You can read more about creating custom templates in this blog post
Update:
Take a look at the answer for this issue from http://aspnetwebstack.codeplex.com/
This behavior is by design.
The overload that you are calling accepts an object parameter called
additionalViewData (http://msdn.microsoft.com/en-us/library/ff406462).
The default implementation of EditorFor ignores this value. You would
have to write a custom editor template to be able to access that
information.

How do you create an EditorTemplate in a Plugin for nopCommerce v2.20

I'm trying to create a plugin for nopCommerce v2.20 that allows the user to request a quote for goods and services by describing the requirements and attaching any relevant documents.
I have started by using http://blog.csharpwebdeveloper.com/2011/09/10/writing-a-plugin-for-nopcommerce-2-x/ as a guide, this has been very good so far. My project is almost identical to the one in the blog post so I'll only add code snippets as I think they are required, so please ask me to expand and provide details if I have left anything important out.
Now I want to add a facility to upload multiple files using uploadify and have decided based on the existing code that I should create an EditorTemplate for attachments.
My problem is I can't work out how to setup my template in a way that can be located by the MVC framework when I use the following line of code to get the template.
#Html.EditorFor(m => m.Attachment)
In my model I’m using the UIHintAttribute("Attachments") on the Attachment property to identify the template with no noticeable effect.
I have created a folder below the "Views" folder called "EditorTemplates" and added a file called "Attachments.cshtml" with the build action set to "Embedded Resource", contents below:
#model int
#using Nop.Core;
#{
var randomNumber = CommonHelper.GenerateRandomInteger();
var clientId = "download" + randomNumber;
var downloadService = EngineContext.Current.Resolve();
var download = downloadService.GetDownloadById(Model);
}
<div>This is a download control #string.Format("randomNumber = {0}, clientId = {1}, download = {2}", randomNumber, clientId, download);</div>
I intend to implement the template once I can get the MVC framework to resolve its location.
So is it possible to have an editor template in a plugin (a separate class library from the main project) and if so what do I need to do to enable the MVC framework to resolve my template location?
I'd also like to add I'm quite new to MVC, Razor, and nopCommerce, sorry in advance if I missed something obvious.
As a side, could you suggest a better title for my question as stackoverflow tells me that it appears subjective?
thanks
If you are trying to supply an editor template without pre-compilation (which is probably the best way until you get into some more advanced scenarios) you will want to set the BuildAction as "Content" - not "EmbeddedResource".
Also, make sure your editor template is in one of the following directory structures (you mentioned it was under "Views" which is incorrect):
/Views/{ControllerName}/EditorTemplates/Attachments.cshtml
/Views/Shared/EditorTemplates/Attachments.cshtml
/Areas/{AreaName}/Views/{ControllerName}/EditorTemplates/Attachments.cshtml
/Areas/{AreaName}/Views/Shared/EditorTemplates/Attachments.cshtml
If you do want to embed the templates as part of a separate library, I suggest you look at this post from Chris Van De Steeg.

rails best way to receive xml data from flex application

Can anybody give me any hints on that? I'm able to display xml content on my swf file but how can I send the changed xml file back to my rails Server?
Thanks in advance!
Markus
RestfulX is by far the best way to do this with Rails :).
Check out their cool examples to get running, it takes 5 minutes. You can generate an application based on models (like Page/Post/Comment/Category...) that'll look like this:
(source: github.com)
You basically run 3 commands and you have a full CMS. And, by default, everything happens via XML, but that's converted (serialized and deserialized) to and from xml, so you can use class objects in ActionScript. You can easily change that to AMF/JSON if you needed to, which is very powerful. Then you can customize everything from there: create a class (MyVideo), add properties (title, url, description, comments), manipulate them in ActionScript, then just do create/update/destroy/save/show, and it handles all the xml requests to/from Rails.
They've solved hardcore things like authentication and session management, file uploading, nested sets and list, etc, which you've probably already run into or will. It's very cool.
Everything works via REST (and CRUD operations), which Rails takes full advantage of. If you just want to use ruby (and not Rails), you can do that no problem. Or if you just wanted to use Flex and no backend, but still wanted to read/write XML without having to create a whole library to handle that, same thing; they handle it all.
You just do:
Rx.models.index(Project) (if you had a my.package.Project class), and it'd return:
<?xml version="1.0" encoding="UTF-8"?>
<projects type="array">
<project>
<completed type="boolean">false</completed>
<created_at type="datetime">2008/07/09 20:08:28</created_at>
<end_date type="date">2008/07/09</end_date>
<id type="integer">490909803</id>
<name>Project4NameString</name>
<notes>Project4NotesText</notes>
<start_date type="date">2008/07/09</start_date>
<updated_at type="datetime">2008/07/09 20:08:28</updated_at>
<user_id type="integer">276171944</user_id>
</project>
</projects>
Then if you wanted to save it (or delete it), you'd just do something like:
var projects:IList = Rx.models.index(Project);
var project:Project = projects.getItemAt(0); // first item in IList;
project.title = "My New Title!";
project.save();
// then later, maybe onClick for a Button with label "Delete Project"...
project.delete();
This is by far the best library for XML processing. And they have a very active group which is a plus.
I saw you asked this question about writing xml via Flex. You'll run into lots of edge cases. Try out RestfulX, it's super sick.
Hope that helps.

Resources