Migrating from Swagger 1.5 to 2.0 - Annotations alternative - swagger

We are migrating from Swagger 1.5 to Swagger 2.0 . I found one link which helped me with process to some extent Link
Though i have few problems :
#ApiModelProperty(value = "Some text", position = 1) and #ApiModel are now
#Schema(description ="Some text")
i did not find the alternative for following attributes of #ApiModelProperty in #Schema annotation
position
notes
dataType
and for #ApiModel(value = "somevalue", parent = Parent.class)
I did not find any method/similar method under Schema Interface for parent as well.
what could be the possible alternative for
position
notes
dataType and
parent
in Schema Interface ?
Could anyone help me with that ?
Thanks

Related

How to dynamically set binding type's "formatOptions" and "constraints" in XML with binding?

I have a list of elements (OData set) and use a binding to show this list.
One field is for a quantity value and this value could sometimes need some decimal places.
The requirement is: only show that amount of decimal numbers that is also available in the OData service.
Annotation techniques can't be used.
I 'hacked' something that is misusing a formatter to update the type of a binding. But this is 'a hack' and it is not possible to convert it to XML views. (The reason is a different handling of the scope the formatter will be called).
So I am searching for a working solution for XML views.
The following code would not work but shows the issue:
new sap.m.Input({ // looking for an XML solution with bindings
value: {
path: "Quantity",
type: new sap.ui.model.type.Float({
// formatOptions
maxFractionDigits: "{QuantityDecimals}",
// ...
}, {
// constraints
minimum: 0
}),
// ...
}
});
The maxFractionDigits : "{QuantityDecimals}" should be "dynamic" and not a constant value.
Setting formatOptions and constraints dynamically in XML (via bindings or a declared function) is unfortunately not (yet) supported. But IMHO this is a valid enhancement request that app developers would greatly benefit from, since it encourages declarative programming.
I already asked for the same feature some years ago but in a comment at https://github.com/SAP/openui5/issues/2449#issuecomment-474304965 (See my answer to Frank's question "If XMLViews would allow a way to specify the dynamic constraints as well (e.g. enhanced syntax), would that fix the problem?").
Please create a new issue via https://github.com/SAP/openui5/issues/new with a clear description of what kind of problems the feature would resolve and possibly other use cases (You can add a link to my comment). I'll add my 👍 to your GitHub issue, and hopefully others too.
I'll update this answer as soon as the feature is available.
Get your dynamic number from your model and store it in a JS variable.
var nQuantityDecimals = this.getModel().getProperty("/QuantityDecimals");
new sap.m.Input({
value : {
path : "Quantity",
type : new sap.ui.model.type.Float({
maxFractionDigits : nQuantityDecimals,
source : {
groupingSeparator: ",",
decimalSeparator: ".",
groupingEnabled: false
}
}, {
minimum:0
})
}
}),

Createmeta using jirapython

Trying to know all the mandatory fields for an issue type Testcase in JIRA using the below statement
defined params as list with items projectIds, IssueType = Testcase, IssueType Id =
"jira._get_json('issue/createmeta', params)".
But i am not able to retrieve the fields
output is alist with
projects
issuetypes,
subtask,
description,
avatarUrls,
key,
Self,
expand
Let me know is there any issue with statement I used or please post a way to retrieve all the mandatory fields for specific issue type using jira python
The way I have been doing this for specific fields:
issue = jira.issue(TestCase)
issue_type_name = issue.fields.issuetype.name
issue_type_id = issue.fields.issuetype.id
Another way to do this getting all the meta is:
issue = jira.issue(TestCase)
print(issue.raw)
or
jira.createmeta(projectKeys='TestCaseProject', projectIds=['TestCase'],expand=None)
Source: http://pythonhosted.org/jira/

How to edit an attribute using Xtext?

I want to use Xtext's editor to edit a String attribute of an EObject instead of editing a text file. How can I achieve this? I found this thread but it only mentions the workaround of creating a temp file. There must be a more elegant solution. I thought of creating a custom EditorInput but I'm not sure where to start. Thanks in advance for any pointers!
Since 2.2, the supported solution is using IEditedResourceProvider with an EmbeddedEditorFactory (since editing an attribute belongs to an embedded editor anyway). Sample code in Xtend (the attribute is updated whenever the editor changes):
val injector = MyDslActivator.instance.getInjector(MyDslActivator.COM_EXAMPLE_MY_DSL)
val resourceSet = injector.getInstance(IResourceSetProvider).get(null)
val fileExtension = injector.getInstance(Key.get(String, Names.named(Constants.FILE_EXTENSIONS)))
val resourceProvider = [|
resourceSet.createResource(createURI('''temp.«fileExtension»''')) as XtextResource
]
injector.getInstance(EmbeddedEditorFactory).newEditor(resourceProvider).withParent(parent) => [
createPartialEditor("", editedAttribute ?: "", "", false)
document.addModelListener[_ | editedAttribute = document.get]
]
Based on: EditTemplateDialog source, StackOverflow, Eclipse Forum.

Grails ExtJS pagination

I am using ExtJS 3.3.1 with Grails 2.0 to do pagination on screen, but it does not work as I expect.
I followed the tip posted here: Grails extJS grid paging
JS page
paramNames: {start:'offset',limit:'max',sort:'sort',dir:'order'},
baseParams: {offset:0,max:10},
The pagingToolbar:
this.gridBBar = new Ext.PagingToolbar({
pageSize : 10,
store : this.gridStore,
displayInfo : true,
displayMsg : 'Hiển thị {0} - {1} mục tìm được của {2} kết quả',
emptyMsg : 'Không tìm thấy dữ liệu',
});
Controller:
def result = Floor.createCriteria().list(
max:params.int('max')?:100,
offset:params.int('offset')?:0
)
render ([count:result.totalCount,data:result] as JSON)
but the paging button (Next) was disabled because the store just contained only 10 item, no more to retrieve.
When I change the offset to 10:
paramNames: {start:'offset',limit:'max',sort:'sort',dir:'order'},
baseParams: {offset:10,max:10},
the pagination is work well, except one strange thing: the grid always display the next 10 results (10th-20th record for 1st click, 20th-30th record for 2nd), not the current first 10 results. I don't know what the correct usage of pagination combined from ExtJs and Grails is. If you have experience in this problem, could you please share me some information?
Thank you so much.
Oh how lucky I am. I've got it!
Based on these 2 articles:
1. http://grails.1312388.n4.nabble.com/Find-Count-for-pagination-And-Objects-for-Criteria-td1368528.html
and
2. http://blog.jeffshurts.com/2010/04/grails-pagination-and-criteriabuilder/
I have found the explanation for this. Because the "count" property returned in JSON is got from result.size(), so it always equals to the pageSize of PagingToolbar of the grid's store, so the store will understand that, there is no more any result to retrieve and it will disable the navigation buttons.
The key here is returning the real total result of the query (without attaching pagination constraints). As normal, the createCriteria().list {} will return an ArraysList. But by passing paging params to list as below: (refer to link 1)
DomainClass.createCriteria().list(max : x, offset : y) {
// not pass max : x, offset : y to here, inside the body
}
Grails will return the result as a PagedResultList implicitly (refer to link 2), and it provide us the getTotalCount(). There's no any official documentation of Grails mention this magical issue.
And my problem was solved.

Getting the Schema from an EDMX file

I need to modify the T4 template POCO.tt to retrieve the database schema from the EDMX file. I can see the schema stored in an EntitySet tag in the XML. However I cannot find the schema anywhere when using an EntitySet object.
Anyone know where I would find the database schema?
Thanks
UPDATE
I wrote up my findings on this in a blog post:
http://www.ninjanye.co.uk/2011/06/getting-schema-information-from-edmx.html
http://jnye.co/Posts/3/getting-schema-information-from-an-edmx-file-with-poco
I came across this same problem myself.
First you need to retrieve the EntityContainer from the Storage Model Content (edmx:StorageModels) section of the edmx file
At the top of the tt template (after the MetadataLoader is instantiated and the inputFile is declared) add the following code to get the Storage Model Content EntityContainer
StoreItemCollection sic;
loader.TryCreateStoreItemCollection(inputFile, out sic);
EntityContainer sicEntityContainer = sic.GetItems<EntityContainer>().First();
Then from within the foreach (var entity in ItemCollection.GetItems...) loop you can get the current schema with the following
EntitySet eset = sicEntityContainer.GetEntitySetByName(code.Escape(entity), true);
string schemaName = eset.MetadataProperties["Schema"].Value.ToString();
Note: You may have to repeat the get schema code for ComplexType properties lower down in the tt template
I think I misunderstood your question the first time. Have you examined the edmx schema for any clues?
According to this link: http://msdn.microsoft.com/en-us/library/cc982042.aspx
The schema for applications that
target the .NET Framework version 4 is
defined in the
Microsoft.Data.Entity.Design.Edmx_2.xsd
file. The schema for applications that
target the .NET Framework version 3.5
SP1 is defined in the
Microsoft.Data.Entity.Design.Edmx_1.xsd
file.
Those are in %VS100COMNTOOLS%\..\..\Xml\Schemas\ for VS 2010, and %VS90COMNTOOLS%\..\..\Xml\Schemas\ (the 3.5 only) for VS 2008
I'm working with EF6 and wanted to add a summary comment to the classes being generated by the t4 template. After hacking around for a while, I managed to do it by loading the EDMX file and using XPath to find what I needed.
var xmlContent = XDocument.Load(textTransform.Host.ResolvePath(inputFile));
var edmxNavigator = xmlContent.CreateNavigator();
XmlNamespaceManager nsMgr = new XmlNamespaceManager(edmxNavigator.NameTable);
nsMgr.AddNamespace("edmx", "http://schemas.microsoft.com/ado/2009/11/edmx");
nsMgr.AddNamespace("store", "http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator");
nsMgr.AddNamespace("ssdl", "http://schemas.microsoft.com/ado/2009/11/edm/ssdl");
nsMgr.AddNamespace("cs", "http://schemas.microsoft.com/ado/2009/11/mapping/cs");
//This is the loop that came with the default template
foreach (var entity in typeMapper.GetItemsToGenerate<EntityType>(itemCollection))
{
fileManager.StartNewFile(entity.Name + ".cs");
BeginNamespace(code);
var mappingAttribute = edmxNavigator.SelectSingleNode("/edmx:Edmx/edmx:Runtime/edmx:Mappings/cs:Mapping/cs:EntityContainerMapping/cs:EntitySetMapping/cs:EntityTypeMapping[#TypeName=\"" + entity.FullName + "\"]/cs:MappingFragment/#StoreEntitySet", nsMgr);
var entitySet = edmxNavigator.SelectSingleNode("/edmx:Edmx/edmx:Runtime/edmx:StorageModels/ssdl:Schema/ssdl:EntityContainer/ssdl:EntitySet[#Name=\"" + mappingAttribute.Value + "\"]", nsMgr);
var actualTableName = (entitySet.SelectSingleNode("#Table") ?? entitySet.SelectSingleNode("#Name")).Value;
var actualSchemaName = (entitySet.SelectSingleNode("#Schema", nsMgr) ?? entitySet.SelectSingleNode("#store:Schema", nsMgr)).Value;
#>
<#=codeStringGenerator.UsingDirectives(inHeader: false)#>
/// <summary>
/// Database Object: <#=actualSchemaName#>.<#=actualTableName#>
/// </summary>
<#=codeStringGenerator.EntityClassOpening(entity)#>
See http://brewdawg.github.io/Tiraggo.Edmx/ you can install it via NuGet within Visual Studio and it serves up ALL of the metadata from your EDMX files that Microsoft hides from you, very simple, works great. You want access to all that low level storage information like your property SQL types, the schema, it's all there. You can even use the Sample Windows.Forms app in the github repo to set a breakpoint and examine the data.
Facing this issue a few weeks ago. As a result create Xslt transformation of EDMX to XSD. https://wash-inside-out.blogspot.com/2022/12/edmx-file-to-xsd-with-xslt.html

Resources