Skip to content

Latest commit

 

History

History
70 lines (55 loc) · 1.59 KB

body-properties-names-camel-case.md

File metadata and controls

70 lines (55 loc) · 1.59 KB

BodyPropertiesNamesCamelCase

Description

This violation is flagged if a request body parameter's property name (BodyPropertiesNamesCamelCase) is not in camelCase format. This is because the model's properties are sent across the wire and must adhere to common Json conventions for naming. This implies that every property name must start with a lower cased letter and all subsequent words within the name must start with a capital letter. In cases where there are acronyms involved, a maximum of three contiguous capital letters are allowed (acronyms should not be longer that 2 characters - see https://msdn.microsoft.com/en-us/library/141e06ef(v=vs.71).aspx, third upper case could be start of next word). Eg: redisCache, publicIPAddress, location are valid, but sampleSQLQuery is not (must be renamed as sampleSqlQuery).

How to fix

Convert the property name string into camelCase format as suggested in the description

Effect on generated code

Before

Spec


"ModelDefinition":{
    "properties":{
        "ModelProperty1":{
            "type":"string"
        }
    }
}

Generated code

public class FooParameter1 {}

After

Spec


"parameters": [
    {
        "name": "foo",
        "in": "body",
        "schema": {
            "$ref": "#/definition/FooCreationSettings"
        }
    }
],

"definitions": {
    "FooCreationSettings": {
        "type": "object",
        "properties": {}
    }
}

Generated code

public class FooCreationSettings {}