{"action":"created","issue":{"url":"https://api.github.com/repos/JamesNK/Newtonsoft.Json.Schema/issues/7","labels_url":"https://api.github.com/repos/JamesNK/Newtonsoft.Json.Schema/issues/7/labels{/name}","comments_url":"https://api.github.com/repos/JamesNK/Newtonsoft.Json.Schema/issues/7/comments","events_url":"https://api.github.com/repos/JamesNK/Newtonsoft.Json.Schema/issues/7/events","html_url":"https://github.com/JamesNK/Newtonsoft.Json.Schema/issues/7","id":57106071,"number":7,"title":"Schema generation - Add Format customization","user":{"login":"payoff","id":142235,"avatar_url":"https://avatars.githubusercontent.com/u/142235?v=3","gravatar_id":"","url":"https://api.github.com/users/payoff","html_url":"https://github.com/payoff","followers_url":"https://api.github.com/users/payoff/followers","following_url":"https://api.github.com/users/payoff/following{/other_user}","gists_url":"https://api.github.com/users/payoff/gists{/gist_id}","starred_url":"https://api.github.com/users/payoff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/payoff/subscriptions","organizations_url":"https://api.github.com/users/payoff/orgs","repos_url":"https://api.github.com/users/payoff/repos","events_url":"https://api.github.com/users/payoff/events{/privacy}","received_events_url":"https://api.github.com/users/payoff/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-02-09T23:20:54Z","updated_at":"2015-02-10T10:19:35Z","closed_at":null,"body":"The only way to generate a schema \"format\" is to use DataAnnotation:\r\nschema.Format = DataAnnotationHelpers.GetFormat(memberProperty);\r\n\r\nJson Schema should allow to customize format and produce something like:\r\nhttps://developers.google.com/discovery/v1/type-format\r\nor: https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#data-types\r\n\r\nex:     \"Long\": {\r\n      \"type\": \"integer\",\r\n      \"format\": \"int64\"\r\n    },\r\n\r\nMic."},"comment":{"url":"https://api.github.com/repos/JamesNK/Newtonsoft.Json.Schema/issues/comments/73676006","html_url":"https://github.com/JamesNK/Newtonsoft.Json.Schema/issues/7#issuecomment-73676006","issue_url":"https://api.github.com/repos/JamesNK/Newtonsoft.Json.Schema/issues/7","id":73676006,"user":{"login":"payoff","id":142235,"avatar_url":"https://avatars.githubusercontent.com/u/142235?v=3","gravatar_id":"","url":"https://api.github.com/users/payoff","html_url":"https://github.com/payoff","followers_url":"https://api.github.com/users/payoff/followers","following_url":"https://api.github.com/users/payoff/following{/other_user}","gists_url":"https://api.github.com/users/payoff/gists{/gist_id}","starred_url":"https://api.github.com/users/payoff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/payoff/subscriptions","organizations_url":"https://api.github.com/users/payoff/orgs","repos_url":"https://api.github.com/users/payoff/repos","events_url":"https://api.github.com/users/payoff/events{/privacy}","received_events_url":"https://api.github.com/users/payoff/received_events","type":"User","site_admin":false},"created_at":"2015-02-10T10:19:35Z","updated_at":"2015-02-10T10:19:35Z","body":"The quick & dirty answer is yes to both.\r\nI've seen the JSchemaGenerationProvider  but I discarded immediately that way.\r\n\r\nI think that a refactoring can be done in this way:\r\nAdd a IList<JFormatProvider> FormatProviders to JSchemaGenerator.\r\n\r\nCreate a JFormatProvider like this:\r\n    public abstract class JFormatProvider\r\n    {\r\n       // tell you if can be used with current content item\r\n        public abstract bool CanBeUsedWith(JSchemaTypeGenerationContext context);\r\n        // generate the format\r\n        public abstract string GetFormat(JsonProperty context);\r\n        // check validity\r\n        public abstract bool Validate(string format);\r\n    }\r\nCanBeUsedWith tells you if it can be used when you add Format in PopulateSchema, if so you can call GetFormat.\r\nThe validate contains the code that check if this is valid, when you validate.\r\n\r\nYou can split all the logic of DataAnnotationHelpers.GetFormat in JFormatProvider like:\r\nUriFormatDataAnnotationsProvider,\r\nPhoneFormatDataAnnotationsProvider,\r\nand user can add new custom implementation or remove default implementation that need to be customized.\r\n\r\n\r\n\r\n\r\n"}}