When generating swagger is there a best practice on wither to use annotation or XML Comments. I have a number of pointend with both xml comments and annotation. Should the endpoints just contain one or the other.
Related
I have a Web API project I am working on in Visual Studio 2013, and I'd like for my Controllers to accept a comma separated list of values via the query string, similar to this:
http://localhost:12345/api/Procedures/1?embed=doctors,drugs&fields=fieldA,fieldB,fieldC
The reason for this is that I'd like to be able to control if related resources (additional tables) are queried via custom embedding using the embed parameter, and control what fields are returned from the base object using the fields parameter.
I've done some searching on Google but most of what is being suggested relates to extending IModelBinder (http://www.strathweb.com/2013/04/asp-net-web-api-parameter-binding-part-1-understanding-binding-from-uri/) or setting up a custom ActionFilterAttribute (Convert custom action filter for Web API use?) which seems like overkill for something relatively simple.
FYI I am using an Entity Framework dbContext class to connect to my database.
The comma character does not have any specific meaning in HTTP query strings so it does not get treated as a separator by out-of-the-box model binding mechanisms.
As far as I know the approach you mentioned with custom attributes is the simplest you can get. And it does not look like an overkill considering you will only implement the attribute once and use everywhere.
I'm using the XML Tree API and the XML Parser API in c++, and I would like to prohibit entities creation in my XML documents.
What is the best way to do that when using these API's?
I've only seen examples of how to prohibit DTD entities when using XML Reader, and none when using the XML Tree or Parser API.
Thanks!
When using the tree API, you can call xmlGetIntSubset and inspect the xmlDtd structure to check whether a document contains entity declarations. When using the SAX parser, you can register an entityDeclSAXFunc callback.
I'm newbie in doctrine 2. i want to know which mapping required for doctrine 2?
I create my Annotation map with all columns, methods and etc.
I need to know it's required to define XML or YAML mapping for any kind of features in doctrine 2 and without them which feature i haven't?
http://docs.doctrine-project.org/projects/doctrine-orm/en/2.0.x/reference/basic-mapping.html
You only need to use one type of mapping and you've done so already with the annotation approach. This is also the preferred approach from what I gather.
The other mapping methods just let you work the way you prefer. So if you want to have your schema defined away from your model source code. You can use XML or YAML. A lot of the Symfony guys use YAML because it's what the framework is configured with. I personally prefer the annotation method.
How can I edit a xml file using JQGrid? I am using ASP.Net MVC 3.5 with C#. Is it possible to return a JSon object from controller method for this purpose?
Everything is possible. But the most work which you have to do is independ from the jqGrid. Moreover general XML file can be not good represented in a grid. If the deepness of the XML file not so long, you can use subgrid feature of the jqGrid. One more restriction existing in the jqGrid can make the work more comple: jqGrid not support data with attributs other as ids. So if you will have to map attributes to the sub-elements on the server side to be able to use jqGrid.
The ASP.NET MVC site can for example read the XML file with respect of some desirialization methods and initialize the object with the same information as the XML has. Then can use the object to fill the jqGrid and modify the data. Because th data are no mo represented as a XML, the server can use JSON to communicate with the jqGrid. At the end one can use one from wel known serialization methods so save modified data in the XML file back.
Ok, I'll explain. I need to create a datagrid in MVC on the fly (potentially multiple datagrids on a view) depending on a XML file being read in. The file gets looped through and may contain multiple grids of data, the headers and rows are set in the file. The problem being that my application won't know the content of the XML file before reading it so I can't apply it to an IEnumerable model. The idea being to make it generic so that it can read in any XML file I pass to it set up as below and put the data in a sortable datagrid. Is this at all possible with current controls out there? I have tried Teleriks MVC grid and while I can read the data into the grid, I cannot sort the data as this feature will only work when passed a DTO. I have a feeling what I'm looking for can't be done (unless I write a custom HTMLHelper or something) but no harm in asking I guess
My xml will be as such
<xml>
<REPORT>
<HEADERS>
<HEAD>Col1</HEAD>
<HEAD>Col2</HEAD>
</HEADERS>
<ROWS>
<ROW>Data1</ROW>
<ROW>Data2</ROW>
</ROWS>
</REPORT>
</xml>
Thanks
I would advise using the jquery grid. Then write a class to parse the xml and generate the grid javascript in the view, and a second action to parse the xml (again) and generate the json result. MVCCrud may help with the idea there is a generic jquery grid in there but it works off an IQueryable list so would need to be adapted.
I haven't seen a helper extension out there that does what you need.
There are some good ones that work with generic collections (such as Telerik's or MVCContrib's). The sample you provide cannot be translated in to a collection that would be handled by these however: the row needs to have cells that can be matched to the header elements.
<xml>
<REPORT>
<HEADERS>
<HEAD>Col1</HEAD>
<HEAD>Col2</HEAD>
</HEADERS>
<ROWS>
<ROW><CELL>Data1</CELL><CELL>Data2</CELL></ROW>
<ROW><CELL>Data2</CELL><CELL>Data4</CELL></ROW>
</ROWS>
</REPORT>
</xml>
If the XML can be deserialized into a generic collection, it is easy to populate the grid.
Hope this helps.
I'd look into the JQuery Grid. You have to munge the data into the format that it wants, but it gives you a lot of flexibility and nice UI for free. You will still need to write sort code, though.