so, I want to write a definition like this:
components:
accuracy::
$ref: '#/definitions/accuracy'
required: false
and 'override' a required property. But the documentation says:
Any sibling elements of a $ref are ignored. This is because $ref works
by replacing itself and everything on its level with the definition it
is pointing at.
So, is there any way to achieve this behavior?
required is not a property attribute, it's an object attribute containing a list of required properties. So you should use:
MyObject:
type: object
properties:
accuracy:
$ref: '#/definitions/accuracy'
required:
- accuracy
Related
is there a way in dart to define an instance variable of type String to only hold certain values.
For example in TypeScript one can achieve this as follows:
class Test {
name: string;
type: 'Unit' | 'Integration';
}
I've already considered defining an enum, however as far as I'm concerned you can't provide enums with custom values in dart.
In the past when I designed APIs , for both 2.0 and 3.0 version, I used camel case convention for property names. This time I could have the necessity of use embedded underscore and capital letter for property name. Is this allowed by openapi? Can I use mix mode?
I searched for naming convention of property name but I' havent found.
Thanks
As far as I know any valid string is allowed. Quoting and escaping is possible to create a valid string.
all this works:
foo-bar:
type: string
foo_bar:
type: string
'foo-bar':
type: string
'foo_bar':
type: string
"foo_bar":
type: string
"foo bar":
type: string
foo bar:
type: string
"foo: bar":
type: string
Can you import a component that is defined in an other OpenAPI file?
Suppose I have two openAPI files:
openAPI.yaml and otherOpenAPI.yaml.
In openAPI.yml I want to use the myItem component that is defined in otherOpenAPI.yaml
Can I do something in the likes of:
$ref: './otherOpenAPI.yaml/components/myItem ?
You can use:
$ref: './otherOpenApi.yaml#/components/MyItem'
I have the following domain model class:
class UserSettings
{
static mapping = {
id name: 'pid', generator: 'assigned'
}
Integer pid
}
And I'm trying to get an instance of the user settings like this:
UserSettings.get(new Integer("12345"))
However, I get the following error
Provided id of the wrong type for class UserSettings. Expected: class java.lang.Integer, got class java.lang.Long
I've also tried passing it a basic int type, and I get the same error. It's like somewhere along the way the "get" method casts my Integer into a Long. Changing the type of the "pid" property in the UserSettings domain class to Long fixes things, however, since I'm integrating with a legacy database, I need the ID to be an Integer not a Long.
In general don't use new Integer, new Long, new Boolean, etc. Use literals and let Java autobox the values for you. If you look at the source of the Integer and Long you'll see that their valueOf methods (which are used when autoboxing) keep a cache of 256 of the smaller values. This won't result in a significant savings but is a good idea, and since you get the same thing with the constructor and valueOf, it's best to always use valueOf.
Further, GORM will convert the input id to the correct type for the domain class. This is why SomeDomainClass.get(params.id) works in controllers - even though all params are strings, GORM can easily convert from a string to a numeric type.
So your best bet here is to work less:
UserSettings.get("12345")
I'm analyzing the DBGrids.pas unit. There's a TColumn class which have published the FieldName property
property FieldName: String read FFieldName write SetFieldName;
It's declared as a string but in the object inspector it's appear as a editable combobox (TDataFieldProperty)
I analyzed almost all DBGrids unit and can't find place where that trick is done. Where should I look?
What you're looking for - dear past me - is the RegisterPropertyEditor method.
Call RegisterPropertyEditor to associate the property editor class
specified by the EditorClass parameter with the property type
specified by the PropertyType parameter.
In your case you need a TDataFieldProperty so it will be like:
RegisterPropertyEditor(TypeInfo(string), TColumn, 'FieldName', TDataFieldProperty);