I am not sure how to specify annotation for an input string parameter for a rest call. Where input parameter can take one of three possible string values.
If I have to assume there will be a drop down menu with these three value (containers/bundles/web) and the user will chose one of them. Previously I am referring to this documentation to create annotation for an in parameters.
I am trying to annotate go code, so that I can generate swagger.yaml automatically (swagger generate spec -o ./swagger.yaml --scan-models). Unfortunately, I couldn't find an annotated example that expects enums or the input parameters is limited to certain values. Looks for some code examples.
some thing like this with enum annotation should work.
// swagger:parameters artifactInfo
type ArtifactTypeParam struct {
// The type of artifact
// in: path
// enum: container,bundle,executbale
// required: true
ArtifactType string `json:"artifactType"`
}
Related
I have an endpoint defined in my API that takes a path parameter.
The valid values for that parameter are already expressed as an enum, which I've defined as a schema component and used in a response.
Two questions:
If you can just use a reference to that schema component as the parameter, why ever set up dedicated parameter components instead of using a generic schema component that you can re-use anywhere?
If you should use parameters instead of generic schemas, can you create a parameter component that refers to a schema component? I can't find any syntax to do this that passes validation.
I'd paste my definitions here but I can't find any formatting option that doesn't make a hideous mess.
If you can just use a reference to that schema component as the parameter, why ever set up dedicated parameter components instead of using a generic schema component that you can re-use anywhere?
Parameter definitions have additional attributes not present in schemas, such as the parameter location in the request (in: path, in: query, etc.), serialization method for array and object values, and others. A schema is just one of the parameter attributes, but a schema alone does not provide enough information to effectively describe a parameter.
can you create a parameter component that refers to a schema component?
Yes. Parameters have a schema, it can be an inline schema or a $ref:
paths:
/something/{role}:
get:
parameters:
- $ref: '#/components/parameters/role'
...
components:
parameters:
role:
in: path
name: role
required: true
schema:
$ref: '#/components/schemas/UserRole' # <-----
schemas:
UserRole:
type: string
enum: [user, admin]
I have a bunch of strings (essentially names of java.lang. classes and some custom classes). In the macro I need to add the type to the function:
q"""propKey[${resolveType(c)(argType)}]($name, classOf[$argType])"""
where argType is String.
So far I tried q"$argType" - but that adds the weird signature propKey[String("java.lang.Integer")](...)
with c.universe.TypeName- there's no method to get a c.universe.Type instance.
c.mirror.staticClass("java.lang.String").toType
In Swift you've got many possible ways to declare a method. You can use the # and _ sign to enforce using parameter names and you can also change the external definition of a parameter.
Somehow the compiler creates an error message for the following method:
func createCoffee(withSugar sugar:Bool, andMilk milk:Bool){
}
// Where I want to call it like this:
createCoffee(withSugar:true, andMilk: true)
Enforcing me to declare the method as followed:
func createCoffee(# sugar:Bool, andMilk milk:Bool){
}
// Resulting in the following way to call it
createCoffee(sugar:true, andMilk: true)
A strange thing in this, declaring the method as followed will not result in this enforced com
func createCoffee(firstParam sugar:Bool, andMilk milk:Bool){
}
// Resulting in the following way to call it
createCoffee(firstParam:true, andMilk: true)
In which way does the compiler decide to allow a different external parameter name?
External parameter names are used for greater description. Having the external parameter name as "with_____" makes Swift and XCode see it as redundant. The first parameter technically would always be "with___ interal parameter name ". It is purely for syntactical reading ease.
I am using spring batch to read pipe (| delimited) separated file which have have 7 field. I created a class called MyLineMapper that extends spring's FieldSetMapper. This class maps field values provided in file to my object (XYZ type). Now the problem is that fieldSet object that i get inside class extending FieldSetMapper contain empty value for field that are not present in delimited values.
For example:
Suppose that the delimited file format is as follows: |ID|Country|City|Pin|
Suppose i provide following line in file: |1|India|
As you can see the above line does not contain information for City and Pin. Therefore, I expect FieldSet object should contain Null value for these two fiels (City and Pin) instead of empty string. I don't want empty value as Null will help me to know if that field was actually present in file or not.
How can I achieve this ? Do I need to extend DelimitedLineTokenizer which I am using for tokenizing ? Or this is a simple way to do this ?
Any help will be appreciated.
From FieldSetMapper javadoc
To customize the way that FieldSet values are converted to the desired
type for injecting into the prototype there are several choices. You
can inject PropertyEditor instances directly through the customEditors
property, or you can override the createBinder(Object) and
initBinder(DataBinder) methods, or you can provide a custom FieldSet
implementation.
Depending on type of your target bean conversion is done using default Spring convention. If you need other type of logic write your own.
In my Visio 2007 UML document I am unable to figure out how I can add an operation to an Interface that returns a generic List<MyCustomType> type.
For example:
Say I have a class named "MyClass" and an Interface named "IFace". IFace has a signature of a method that returns a Generic List of MyClass.
For clarity, here's an example of the C# code:
namespace StackO
{
public interface IFace
{
List<MyClass> SomeMethod(string data);
}
public class MyClass
{
}
}
Here's a screenshot of where I'm stuck:
It seems as though the only way to specify a List<MyClass> as my Return Type is to create another user-defined datatype that is explicitly written as List<MyClass>. If this is the case, so be it. However, I'm posting this in hopes that there is a better/proper way to do this.
How can I define the Return Type of an Operation of a Visio Interface to be a Generic List of a User-Defined Datatype?
In the Class diagram properties > Go to operations > select the return type you are interested in changing and click properties.
In the next dialog you will have option for setting prefix List< and suffix >.
This way you can specify the return type as List<>.
I see this option in Visio 2010. But I am not sure if this option is available in Visio 2007.
There is no such a thing as T1<T2> in UML class diagrams.
If you want to specify that the method returns several values, the correct notation is:
SomeMethod(data: String) : MyClass [*]
This notation is much more powerful than the one used by C#. List<MyClass> SomeMethod(string data) gives no information about the contract of the method. With UML, you know that in:
SomeMethod(data: String) : MyClass [*]
SomethingElse() : String [1..*]
LastExample(number: UnlimitedNatural) : Integer [0..1]
SomeMethod returns a sequence containing zero or more elements. SomethingElse returns a sequence of one or several elements: this sequence is never empty. Finally, LastExample returns an optional value. This could be expressed in C# as int? LastExample(uint number) — see, no IEnumerable here.
Also note that:
SomeMethod(data: String) : MyClass [0..*]
shouldn't be used, since [*] means the same thing and is shorter. As for:
SomeMethod(data: String) : MyClass [0..n]
is incorrect, despite being used a lot on the internet.