Expand C# object to override property name in XML documentation
up vote
0
down vote
favorite
I'm currently building and endpoint (lets call it myendpoint) and would like to be able to manipulate the parameter names to match requirements. Lets say that I have an object called myobject
that contains the following properties name
, address
, addressCity
, and addressState
. However, I need addressCity
and addressState
to show up in the documentation as address-city
and address-state
. Is there a way to override the names of the properties inside the object to accomplish this?
public class myobject
public string name get; set;
public string address get; set;
[JsonProperty("address-city")]
public string addressCity get; set;
[JsonProperty("address-state")]
public string addressState get; set;
/// <summary>
/// Gets some information
/// </summary>
/// <param name="myobject"></param>
/// <returns></returns>
public IHttpActionResult GetInformation([FromURI] Object myobject)
// Code
Current documentation on the help page shows up as:
http://localhost:9999/api/myendpoint?name=name&address=address&addressCity=addressCity&addressState=addressState
I would like it to show up as:
http://localhost:9999/api/myendpoint?name=name&address=address&address-city=address-city&address-state=address-state
I have tried to use multiple attributes such as DisplayName
, JsonProperty
(currently using this but the XML documentation does not pickup on the new name).
Edit: Added function
c# xml api documentation
add a comment |
up vote
0
down vote
favorite
I'm currently building and endpoint (lets call it myendpoint) and would like to be able to manipulate the parameter names to match requirements. Lets say that I have an object called myobject
that contains the following properties name
, address
, addressCity
, and addressState
. However, I need addressCity
and addressState
to show up in the documentation as address-city
and address-state
. Is there a way to override the names of the properties inside the object to accomplish this?
public class myobject
public string name get; set;
public string address get; set;
[JsonProperty("address-city")]
public string addressCity get; set;
[JsonProperty("address-state")]
public string addressState get; set;
/// <summary>
/// Gets some information
/// </summary>
/// <param name="myobject"></param>
/// <returns></returns>
public IHttpActionResult GetInformation([FromURI] Object myobject)
// Code
Current documentation on the help page shows up as:
http://localhost:9999/api/myendpoint?name=name&address=address&addressCity=addressCity&addressState=addressState
I would like it to show up as:
http://localhost:9999/api/myendpoint?name=name&address=address&address-city=address-city&address-state=address-state
I have tried to use multiple attributes such as DisplayName
, JsonProperty
(currently using this but the XML documentation does not pickup on the new name).
Edit: Added function
c# xml api documentation
Where is the reference to the mentioned variables in the added function?
– albert
Nov 9 at 9:10
I'm sorry what are you asking for?
– toClean
Nov 9 at 23:24
You mention in your description a.o. address-state and addressState but in your code snippet none of these words are present,at least I don't see them. These are apparently part ofmyobject
but I don't see any documentation about it.
– albert
Nov 10 at 9:21
@albert I mentioned that they are apart of myobject, but I just wrote the class out as an edit.
– toClean
Nov 12 at 17:50
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm currently building and endpoint (lets call it myendpoint) and would like to be able to manipulate the parameter names to match requirements. Lets say that I have an object called myobject
that contains the following properties name
, address
, addressCity
, and addressState
. However, I need addressCity
and addressState
to show up in the documentation as address-city
and address-state
. Is there a way to override the names of the properties inside the object to accomplish this?
public class myobject
public string name get; set;
public string address get; set;
[JsonProperty("address-city")]
public string addressCity get; set;
[JsonProperty("address-state")]
public string addressState get; set;
/// <summary>
/// Gets some information
/// </summary>
/// <param name="myobject"></param>
/// <returns></returns>
public IHttpActionResult GetInformation([FromURI] Object myobject)
// Code
Current documentation on the help page shows up as:
http://localhost:9999/api/myendpoint?name=name&address=address&addressCity=addressCity&addressState=addressState
I would like it to show up as:
http://localhost:9999/api/myendpoint?name=name&address=address&address-city=address-city&address-state=address-state
I have tried to use multiple attributes such as DisplayName
, JsonProperty
(currently using this but the XML documentation does not pickup on the new name).
Edit: Added function
c# xml api documentation
I'm currently building and endpoint (lets call it myendpoint) and would like to be able to manipulate the parameter names to match requirements. Lets say that I have an object called myobject
that contains the following properties name
, address
, addressCity
, and addressState
. However, I need addressCity
and addressState
to show up in the documentation as address-city
and address-state
. Is there a way to override the names of the properties inside the object to accomplish this?
public class myobject
public string name get; set;
public string address get; set;
[JsonProperty("address-city")]
public string addressCity get; set;
[JsonProperty("address-state")]
public string addressState get; set;
/// <summary>
/// Gets some information
/// </summary>
/// <param name="myobject"></param>
/// <returns></returns>
public IHttpActionResult GetInformation([FromURI] Object myobject)
// Code
Current documentation on the help page shows up as:
http://localhost:9999/api/myendpoint?name=name&address=address&addressCity=addressCity&addressState=addressState
I would like it to show up as:
http://localhost:9999/api/myendpoint?name=name&address=address&address-city=address-city&address-state=address-state
I have tried to use multiple attributes such as DisplayName
, JsonProperty
(currently using this but the XML documentation does not pickup on the new name).
Edit: Added function
c# xml api documentation
c# xml api documentation
edited Nov 12 at 17:52
asked Nov 8 at 18:17
toClean
87
87
Where is the reference to the mentioned variables in the added function?
– albert
Nov 9 at 9:10
I'm sorry what are you asking for?
– toClean
Nov 9 at 23:24
You mention in your description a.o. address-state and addressState but in your code snippet none of these words are present,at least I don't see them. These are apparently part ofmyobject
but I don't see any documentation about it.
– albert
Nov 10 at 9:21
@albert I mentioned that they are apart of myobject, but I just wrote the class out as an edit.
– toClean
Nov 12 at 17:50
add a comment |
Where is the reference to the mentioned variables in the added function?
– albert
Nov 9 at 9:10
I'm sorry what are you asking for?
– toClean
Nov 9 at 23:24
You mention in your description a.o. address-state and addressState but in your code snippet none of these words are present,at least I don't see them. These are apparently part ofmyobject
but I don't see any documentation about it.
– albert
Nov 10 at 9:21
@albert I mentioned that they are apart of myobject, but I just wrote the class out as an edit.
– toClean
Nov 12 at 17:50
Where is the reference to the mentioned variables in the added function?
– albert
Nov 9 at 9:10
Where is the reference to the mentioned variables in the added function?
– albert
Nov 9 at 9:10
I'm sorry what are you asking for?
– toClean
Nov 9 at 23:24
I'm sorry what are you asking for?
– toClean
Nov 9 at 23:24
You mention in your description a.o. address-state and addressState but in your code snippet none of these words are present,at least I don't see them. These are apparently part of
myobject
but I don't see any documentation about it.– albert
Nov 10 at 9:21
You mention in your description a.o. address-state and addressState but in your code snippet none of these words are present,at least I don't see them. These are apparently part of
myobject
but I don't see any documentation about it.– albert
Nov 10 at 9:21
@albert I mentioned that they are apart of myobject, but I just wrote the class out as an edit.
– toClean
Nov 12 at 17:50
@albert I mentioned that they are apart of myobject, but I just wrote the class out as an edit.
– toClean
Nov 12 at 17:50
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53213846%2fexpand-c-sharp-object-to-override-property-name-in-xml-documentation%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Where is the reference to the mentioned variables in the added function?
– albert
Nov 9 at 9:10
I'm sorry what are you asking for?
– toClean
Nov 9 at 23:24
You mention in your description a.o. address-state and addressState but in your code snippet none of these words are present,at least I don't see them. These are apparently part of
myobject
but I don't see any documentation about it.– albert
Nov 10 at 9:21
@albert I mentioned that they are apart of myobject, but I just wrote the class out as an edit.
– toClean
Nov 12 at 17:50