Inconsistency metadata page and service

I have set my jsConfig to this:

JsConfig.Init(new ServiceStack.Text.Config
{
TextCase = TextCase.SnakeCase
});

When I look at my services, the json payload for requests and response shows snake case if I browse to the service using /metadata.

However, when I use postman to post to the service using snake case (I just copied the sample json for the request from the /metadata page, I get an error for all my fields that are marked that it should not be empty, although the fields are provided in snake case. When I change the fields to PascalCase, the service excepts the fields.

I want to use lower snake case throughout. Below see pictures of my metadata pages.

metadata

So doing a post from postman using

{

"file_name": "Customers.csv",

"file_size": "2906",

"record_count": 27,

"user_auth_id": 31,

"inserted_records": 0,

"updated_records": 0,

"deleted_records": 0,

"upload_type": "customeraddedit",

"status_codes_id": 9

}

does not work but the below work.

{

"FileName": "Customers.csv",

"FileSize": "2906",

"RecordCount": 27,

"UserAuthId ": 31,

"InsertedRecords": 0,

"UpdatedRecords": 0,

"DeletedRecords": 0,

"UploadType": "customeraddedit",

"StatusCodesId": 9

}

The Metadata Page shows the C# Typed DTOs view that clients see when using the Typed Service Clients whilst the HTTP Payload Example shows the example wire format for their chosen Content-Type, e.g. serialized JSON in your screenshot.

Prefer to keep the property names reflect the C# DTOs, which is what the .NET Data Type in the column refers to, i.e. not the wire format data type.

I don’t think I was clear. When I use the json type to call the service from javascript (the snake_case properties), then it does not fill the request DTO’s which is PascalCase e.g.

calling post https://localhost/batch with payload

{

"file_name": "Customers.csv",

"file_size": "2906",

"record_count": 27,

"user_auth_id": 31,

"inserted_records": 0,

"updated_records": 0,

"deleted_records": 0,

"upload_type": "customeraddedit",

"status_codes_id": 9

}

cause my request dtos to have nothing in it, and my validation rules say that for e.g. File Name is required. When I in my javascript post request make the payload PascalCase, it works

I’m saying that the discrepancy is due to the Metadata properties reflecting the original C# DTOs Property names & .NET Types not the snake_case of the JSON wire format.

FYI I’ve added the ability to view the DTOs of each API in all supported languages, e.g. you can click on the TypeScript tabs to view the DTOs in TypeScript, e.g:

image

This feature is available from the latest v5.13.3+ that’s now available on MyGet