diff --git a/examples/C#-Examples/bookclubbing.cs b/examples/C#-Examples/bookclubbing.cs index bf3a964..07c953d 100644 --- a/examples/C#-Examples/bookclubbing.cs +++ b/examples/C#-Examples/bookclubbing.cs @@ -1,4 +1,4 @@ -//This file was autogenerated by nSwagger 0.0.1 - changes made to it maybe lost if nSwagger is run again. +//This file was autogenerated by nSwagger 0.0.2 - changes made to it maybe lost if nSwagger is run again. namespace nSwagger { using Newtonsoft.Json; diff --git a/examples/C#-Examples/devconf.cs b/examples/C#-Examples/devconf.cs new file mode 100644 index 0000000..9082ba9 --- /dev/null +++ b/examples/C#-Examples/devconf.cs @@ -0,0 +1,488 @@ +//This file was autogenerated by nSwagger 0.0.2 - changes made to it maybe lost if nSwagger is run again. +namespace nSwagger +{ + using Newtonsoft.Json; + using System; + using System.Diagnostics; + using System.IO; + using System.Net; + using System.Net.Http; + using System.Net.Http.Headers; + using System.Threading; + using System.Threading.Tasks; + + public class DevConfRatings + { + private readonly string url; + private readonly ISwaggerHTTPClient httpClient; + public DevConfRatings(string url = null, ISwaggerHTTPClient httpClient = null) + { + if (!string.IsNullOrWhiteSpace(url)) + { + this.url = url; + } + else + { + this.url = "https://localhost:24110"; + } if ( httpClient == null ) { this . httpClient = new SwaggerHTTPClient ( ) ; } else { this . httpClient = httpClient ; } + + } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("", "RECS0001:Class is declared partial but has only one part", Justification = "This is partial to allow the file to extended in a seperate file if needed. Changes to this file would be lost when the code is regenerated and so supporting a seperate file for this is ideal.")] + public partial class GetRatings + { + public string Email + { + get; + set; + } + } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("", "RECS0001:Class is declared partial but has only one part", Justification = "This is partial to allow the file to extended in a seperate file if needed. Changes to this file would be lost when the code is regenerated and so supporting a seperate file for this is ideal.")] + public partial class RatingSession + { + public string Comment + { + get; + set; + } + + public int Order + { + get; + set; + } + + public int Rating + { + get; + set; + } + + public int SessionId + { + get; + set; + } + } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("", "RECS0001:Class is declared partial but has only one part", Justification = "This is partial to allow the file to extended in a seperate file if needed. Changes to this file would be lost when the code is regenerated and so supporting a seperate file for this is ideal.")] + public partial class Rating + { + public string Email + { + get; + set; + } + + public RatingSession Session1 + { + get; + set; + } + + public RatingSession Session2 + { + get; + set; + } + + public RatingSession Session3 + { + get; + set; + } + + public RatingSession Session4 + { + get; + set; + } + + public RatingSession Session5 + { + get; + set; + } + + public RatingSession Session6 + { + get; + set; + } + + public RatingSession Session7 + { + get; + set; + } + + public RatingSession Session8 + { + get; + set; + } + } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("", "RECS0001:Class is declared partial but has only one part", Justification = "This is partial to allow the file to extended in a seperate file if needed. Changes to this file would be lost when the code is regenerated and so supporting a seperate file for this is ideal.")] + public partial class TimeSlot + { + public string End + { + get; + set; + } + + public int Order + { + get; + set; + } + + public Session[] Sessions + { + get; + set; + } + + public string Start + { + get; + set; + } + } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("", "RECS0001:Class is declared partial but has only one part", Justification = "This is partial to allow the file to extended in a seperate file if needed. Changes to this file would be lost when the code is regenerated and so supporting a seperate file for this is ideal.")] + public partial class Session + { + public int Id + { + get; + set; + } + + public string Presenter + { + get; + set; + } + + public string Title + { + get; + set; + } + + public string Track + { + get; + set; + } + } + + // + // Gets previously entered reviews + // + // + // Success + // + //email or token for lookup + public async Task> Rating_PostGetRatingAsync(GetRatings request) + { + { + var response = await httpClient.PostAsync(new Uri(url + "/api/rating/history", UriKind.Absolute), new SwaggerHTTPClientOptions(TimeSpan.FromSeconds(30)), new StringContent(JsonConvert.SerializeObject(request))); + if (response == null) + { + return new APIResponse(false); + } + + switch ((int)response.StatusCode) + { + case 200: + { + var data = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); + return new APIResponse(successData: data, statusCode: response.StatusCode); + } + + case 400: + { + return new APIResponse(response.StatusCode); + } + + case 404: + { + return new APIResponse(response.StatusCode); + } + + default: + { + return new APIResponse(response.StatusCode); + } + } + } + } + + // + // Used to add a rating or update a rating in the system + // + // + // Success + // + //The rating value + public async Task> Rating_PostAddRatingAsync(Rating rating) + { + { + var response = await httpClient.PostAsync(new Uri(url + "/api/Rating", UriKind.Absolute), new SwaggerHTTPClientOptions(TimeSpan.FromSeconds(30)), new StringContent(JsonConvert.SerializeObject(rating))); + if (response == null) + { + return new APIResponse(false); + } + + switch ((int)response.StatusCode) + { + case 400: + { + return new APIResponse(response.StatusCode); + } + + case 401: + { + return new APIResponse(response.StatusCode); + } + + case 204: + { + var data = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); + return new APIResponse(successData: data, statusCode: response.StatusCode); + } + + default: + { + return new APIResponse(response.StatusCode); + } + } + } + } + + // + // Gets all the sessions + // + // + // Success + // + public async Task> Session_GetSessionsAsync() + { + { + var response = await httpClient.GetAsync(new Uri(url + "/api/Session", UriKind.Absolute), new SwaggerHTTPClientOptions(TimeSpan.FromSeconds(30))); + if (response == null) + { + return new APIResponse(false); + } + + switch ((int)response.StatusCode) + { + case 200: + { + var data = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); + return new APIResponse(successData: data, statusCode: response.StatusCode); + } + + default: + { + return new APIResponse(response.StatusCode); + } + } + } + } + } public class SwaggerHTTPClientOptions + { + public TimeSpan Timeout { get; } + + public SwaggerHTTPClientOptions(TimeSpan timeout) + { + Timeout = timeout; + } + } + + public interface ISwaggerHTTPClient + { + Task PutAsync(Uri uri, SwaggerHTTPClientOptions httpOptions, HttpContent content = null, string token = null); + Task PostAsync(Uri uri, SwaggerHTTPClientOptions httpOptions, HttpContent content = null, string token = null); + Task HeadAsync(Uri uri, SwaggerHTTPClientOptions httpOptions, string token = null); + Task OptionsAsync(Uri uri, SwaggerHTTPClientOptions httpOptions, string token = null); + Task PatchAsync(Uri uri, SwaggerHTTPClientOptions httpOptions, HttpContent content, string token = null); + Task DeleteAsync(Uri uri, SwaggerHTTPClientOptions httpOptions, string token = null); + Task GetAsync(Uri uri, SwaggerHTTPClientOptions httpOptions, string token = null); + } + + class SwaggerHTTPClient : ISwaggerHTTPClient + { + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "This is done interntionally as each place that calls this will dispose it")] + private static HttpClient CreateClient() + { + var cookieJar = new CookieContainer(); + var httpHandler = new HttpClientHandler + { + CookieContainer = cookieJar, + AllowAutoRedirect = true, + UseCookies = true + }; + + var client = new HttpClient(httpHandler, true); + client.DefaultRequestHeaders.CacheControl = new CacheControlHeaderValue + { + NoCache = true, + NoStore = true, + Private = true, + ProxyRevalidate = true, + MustRevalidate = true + }; + + return client; + } + + public async Task PutAsync(Uri uri, SwaggerHTTPClientOptions httpOptions, HttpContent content = null, string token = null) => await HTTPCallAsync("put", uri, httpOptions, content, token); + + public async Task PostAsync(Uri uri, SwaggerHTTPClientOptions httpOptions, HttpContent content = null, string token = null) => await HTTPCallAsync("post", uri, httpOptions, content, token); + + private static async Task HTTPCallAsync(string method, Uri uri, SwaggerHTTPClientOptions options, HttpContent content = null, string token = null) + { + using (var client = CreateClient()) + { + using (var cancellationTokenSource = new CancellationTokenSource(options.Timeout)) + { + var errorMessage = string.Empty; + try + { + if (content != null) + { + content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); + } + + if (!string.IsNullOrWhiteSpace(token)) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", token); + } + + var response = default(HttpResponseMessage); + switch (method.ToUpperInvariant()) + { + case "DELETE": + { + response = await client.DeleteAsync(uri, cancellationTokenSource.Token); + break; + } + case "POST": + { + response = await client.PostAsync(uri, content, cancellationTokenSource.Token); + break; + } + case "PUT": + { + response = await client.PutAsync(uri, content, cancellationTokenSource.Token); + break; + } + case "GET": + { + response = await client.GetAsync(uri, HttpCompletionOption.ResponseContentRead, cancellationTokenSource.Token); + break; + } + case "HEAD": + { + response = await client.SendAsync(new HttpRequestMessage + { + Method = new HttpMethod(method), + RequestUri = uri + }, HttpCompletionOption.ResponseHeadersRead, cancellationTokenSource.Token); + + break; + } + case "OPTIONS": + { + response = await client.SendAsync(new HttpRequestMessage + { + Method = new HttpMethod(method), + RequestUri = uri + }, HttpCompletionOption.ResponseContentRead, cancellationTokenSource.Token); + + break; + } + case "PATCH": + { + response = await client.SendAsync(new HttpRequestMessage + { + Method = new HttpMethod(method), + RequestUri = uri, + Content = content + }, HttpCompletionOption.ResponseContentRead, cancellationTokenSource.Token); + + break; + } + } + + #if DEBUG + Debug.WriteLine($"HTTP {method} to {uri} returned {response.StatusCode} with content {await response.Content?.ReadAsStringAsync()}"); + #endif + return response; + } + catch (FileNotFoundException) { errorMessage = $"HTTP {method} exception - file not found exception"; /* this can happen if WP cannot resolve the server */ } + catch (WebException) { errorMessage = $"HTTP {method} exception - web exception"; } + catch (HttpRequestException) { errorMessage = $"HTTP {method} exception - http exception"; } + catch (TaskCanceledException) { errorMessage = $"HTTP {method} exception - task cancelled exception"; } + catch (UnauthorizedAccessException) { errorMessage = $"HTTP {method} exception - unauth exception"; } + + #if DEBUG + Debug.WriteLine(errorMessage); + #endif + } + } + + return null; + } + + public async Task HeadAsync(Uri uri, SwaggerHTTPClientOptions httpOptions, string token = null) => await HTTPCallAsync("head", uri, httpOptions, token: token); + + public async Task OptionsAsync(Uri uri, SwaggerHTTPClientOptions httpOptions, string token = null) => await HTTPCallAsync("options", uri, httpOptions, token: token); + + public async Task PatchAsync(Uri uri, SwaggerHTTPClientOptions httpOptions, HttpContent content, string token = null) => await HTTPCallAsync("patch", uri, httpOptions, content, token: token); + + public async Task DeleteAsync(Uri uri, SwaggerHTTPClientOptions httpOptions, string token = null) => await HTTPCallAsync("delete", uri, httpOptions, token: token); + + public async Task GetAsync(Uri uri, SwaggerHTTPClientOptions httpOptions, string token = null) => await HTTPCallAsync("get", uri, httpOptions, token: token); + } + + public class APIResponse + { + public APIResponse(dynamic data, HttpStatusCode statusCode) : this(statusCode) + { + Data = data; + } + + public APIResponse(T successData, HttpStatusCode statusCode) : this(statusCode) + { + SuccessData = successData; + SuccessDataAvailable = true; + } + + public bool Success { get; } + + public APIResponse(bool success) + { + Success = success; + } + + public APIResponse(HttpStatusCode statusCode) : this((int)statusCode >= 200 && (int)statusCode <= 299) + { + HTTPStatusCode = statusCode; + } + + public dynamic Data { get; } + + public T SuccessData { get; } + + public HttpStatusCode? HTTPStatusCode { get; } + + public bool SuccessDataAvailable { get; } + } + +} \ No newline at end of file diff --git a/examples/C#-Examples/kiosk.cs b/examples/C#-Examples/kiosk.cs index 46ee0dd..ef3f21c 100644 --- a/examples/C#-Examples/kiosk.cs +++ b/examples/C#-Examples/kiosk.cs @@ -1,4 +1,4 @@ -//This file was autogenerated by nSwagger 0.0.1 - changes made to it maybe lost if nSwagger is run again. +//This file was autogenerated by nSwagger 0.0.2 - changes made to it maybe lost if nSwagger is run again. namespace nSwagger { using Newtonsoft.Json; diff --git a/examples/C#-Examples/petstore-expanded.cs b/examples/C#-Examples/petstore-expanded.cs index 86da39e..7fee1f4 100644 --- a/examples/C#-Examples/petstore-expanded.cs +++ b/examples/C#-Examples/petstore-expanded.cs @@ -1,4 +1,4 @@ -//This file was autogenerated by nSwagger 0.0.1 - changes made to it maybe lost if nSwagger is run again. +//This file was autogenerated by nSwagger 0.0.2 - changes made to it maybe lost if nSwagger is run again. namespace nSwagger { using Newtonsoft.Json; diff --git a/examples/C#-Examples/petstore-minimal.cs b/examples/C#-Examples/petstore-minimal.cs index e568a7c..5d0d116 100644 --- a/examples/C#-Examples/petstore-minimal.cs +++ b/examples/C#-Examples/petstore-minimal.cs @@ -1,4 +1,4 @@ -//This file was autogenerated by nSwagger 0.0.1 - changes made to it maybe lost if nSwagger is run again. +//This file was autogenerated by nSwagger 0.0.2 - changes made to it maybe lost if nSwagger is run again. namespace nSwagger { using Newtonsoft.Json; diff --git a/examples/C#-Examples/petstore-simple.cs b/examples/C#-Examples/petstore-simple.cs index a91d93a..cab3810 100644 --- a/examples/C#-Examples/petstore-simple.cs +++ b/examples/C#-Examples/petstore-simple.cs @@ -1,4 +1,4 @@ -//This file was autogenerated by nSwagger 0.0.1 - changes made to it maybe lost if nSwagger is run again. +//This file was autogenerated by nSwagger 0.0.2 - changes made to it maybe lost if nSwagger is run again. namespace nSwagger { using Newtonsoft.Json; diff --git a/examples/C#-Examples/petstore-with-external-docs.cs b/examples/C#-Examples/petstore-with-external-docs.cs index 66c6c2f..f47dda0 100644 --- a/examples/C#-Examples/petstore-with-external-docs.cs +++ b/examples/C#-Examples/petstore-with-external-docs.cs @@ -1,4 +1,4 @@ -//This file was autogenerated by nSwagger 0.0.1 - changes made to it maybe lost if nSwagger is run again. +//This file was autogenerated by nSwagger 0.0.2 - changes made to it maybe lost if nSwagger is run again. namespace nSwagger { using Newtonsoft.Json; diff --git a/examples/C#-Examples/petstore.cs b/examples/C#-Examples/petstore.cs index a73b017..e07083b 100644 --- a/examples/C#-Examples/petstore.cs +++ b/examples/C#-Examples/petstore.cs @@ -1,4 +1,4 @@ -//This file was autogenerated by nSwagger 0.0.1 - changes made to it maybe lost if nSwagger is run again. +//This file was autogenerated by nSwagger 0.0.2 - changes made to it maybe lost if nSwagger is run again. namespace nSwagger { using Newtonsoft.Json; diff --git a/examples/C#-Examples/s2b.cs b/examples/C#-Examples/s2b.cs index 28739ff..e526195 100644 --- a/examples/C#-Examples/s2b.cs +++ b/examples/C#-Examples/s2b.cs @@ -1,4 +1,4 @@ -//This file was autogenerated by nSwagger 0.0.1 - changes made to it maybe lost if nSwagger is run again. +//This file was autogenerated by nSwagger 0.0.2 - changes made to it maybe lost if nSwagger is run again. namespace nSwagger { using Newtonsoft.Json; diff --git a/examples/TS-Examples/bookclubbing.ts b/examples/TS-Examples/bookclubbing.ts index 463db59..821da76 100644 --- a/examples/TS-Examples/bookclubbing.ts +++ b/examples/TS-Examples/bookclubbing.ts @@ -1,28 +1,28 @@ -// This file was autogenerated by nSwagger 0.0.1 - changes made to it maybe lost if nSwagger is run again +// This file was autogenerated by nSwagger 0.0.2 - changes made to it maybe lost if nSwagger is run again namespace nSwagger { export module BookClubbingAPI { - export class ResendPinRequest { + export interface ResendPinRequest { Email: string; } - export class AuthRequest { + export interface AuthRequest { Email: string; Password: string; } - export class ImageParameters { + export interface ImageParameters { Height: number; Width: number; } - export class BookItem { + export interface BookItem { AffiliateLink: string; Author: string; CheckedOut: string; CheckedOutToId: string; CheckedOutToName: string; Description: string; - Genres: GenreResponseItem[]; + Genres: Array; GoodReadsId: string; GutenburgId: string; Id: string; @@ -53,24 +53,24 @@ namespace nSwagger { Damaged } - export class GenreResponseItem { + export interface GenreResponseItem { Aliases: any; Id: number; Name: string; } - export class FilterParameters { + export interface FilterParameters { Skip: number; Top: number; } - export class CumulitiveRatingResponse { + export interface CumulitiveRatingResponse { NotEnoughRatings: boolean; - Ratings: RatingResponse[]; + Ratings: Array; Score: number; } - export class RatingResponse { + export interface RatingResponse { Book: BookItem; Note: string; Rating: number; @@ -81,12 +81,12 @@ namespace nSwagger { Book } - export class Top10ResponseItem { + export interface Top10ResponseItem { Book: BookItem; Rating: number; } - export class AddBookToRequest { + export interface AddBookToRequest { AddToClub: boolean; BookId: string; ClubID: string; @@ -102,16 +102,16 @@ namespace nSwagger { Damaged } - export class BookSearchRequest { + export interface BookSearchRequest { Latitude: number; Longitude: number; Query: string; } - export class BookCreateRequest { + export interface BookCreateRequest { Author: string; Description: string; - Genres: number[]; + Genres: Array; GoodReadsId: string; GutenburgId: string; ImageUrl: string; @@ -125,31 +125,31 @@ namespace nSwagger { Title: string; } - export class ReadResponseItem { + export interface ReadResponseItem { Book: BookItem; When: string; } - export class CollectionResponseReadResponseItem { - Items: ReadResponseItem[]; + export interface CollectionResponseReadResponseItem { + Items: Array; Next: string; Previous: string; TotalCount: number; } - export class Position { + export interface Position { Latitude: number; Longitude: number; } - export class CollectionResponseClubGetMemberResponse { - Items: ClubGetMemberResponse[]; + export interface CollectionResponseClubGetMemberResponse { + Items: Array; Next: string; Previous: string; TotalCount: number; } - export class ClubGetMemberResponse { + export interface ClubGetMemberResponse { Member: UserResponse; RelationshipType: string; Self: boolean; @@ -161,7 +161,7 @@ namespace nSwagger { Follower } - export class UserResponse { + export interface UserResponse { DayOfBirth: number; Email: string; FirstName: string; @@ -183,28 +183,28 @@ namespace nSwagger { YearOfBirth: number; } - export class ChangeRoleRequest { + export interface ChangeRoleRequest { Admin: boolean; UserId: string; } - export class ClubSearchRequest { + export interface ClubSearchRequest { Query: string; } - export class CollectionResponseClubResponseItem { - Items: ClubResponseItem[]; + export interface CollectionResponseClubResponseItem { + Items: Array; Next: string; Previous: string; TotalCount: number; } - export class ClubResponseItem { + export interface ClubResponseItem { Id: string; ClubName: string; } - export class ClubGetResponse { + export interface ClubGetResponse { AddToBoxRule: string; BookCount: number; CanFollow: boolean; @@ -250,7 +250,7 @@ namespace nSwagger { MultiRead } - export class ClubUpdateRequest { + export interface ClubUpdateRequest { SeeFollowers: boolean; SeeMembers: boolean; AddToBoxRule: string; @@ -289,7 +289,7 @@ namespace nSwagger { Hidden } - export class ClubCreateRequest { + export interface ClubCreateRequest { AddToBoxRule: string; CanFollow: boolean; ClubStyle: string; @@ -326,14 +326,14 @@ namespace nSwagger { Hidden } - export class CollectionResponseClubInviteItem { - Items: ClubInviteItem[]; + export interface CollectionResponseClubInviteItem { + Items: Array; Next: string; Previous: string; TotalCount: number; } - export class ClubInviteItem { + export interface ClubInviteItem { ClubId: string; ClubName: string; InviteId: string; @@ -345,25 +345,25 @@ namespace nSwagger { SenderId: string; } - export class AddClubInviteRequest { + export interface AddClubInviteRequest { Message: string; UserId: string; } - export class ClubJoinRequest { + export interface ClubJoinRequest { Club: string; Invite: string; JustFollow: boolean; } - export class CollectionResponseBookItem { - Items: BookItem[]; + export interface CollectionResponseBookItem { + Items: Array; Next: string; Previous: string; TotalCount: number; } - export class EventItem { + export interface EventItem { City: string; ClubId: string; ClubName: string; @@ -384,7 +384,7 @@ namespace nSwagger { Title: string; } - export class EventCreateRequest { + export interface EventCreateRequest { City: string; Country: string; Description: string; @@ -398,31 +398,31 @@ namespace nSwagger { Title: string; } - export class CollectionResponseEventItem { - Items: EventItem[]; + export interface CollectionResponseEventItem { + Items: Array; Next: string; Previous: string; TotalCount: number; } - export class ForgotPasswordRequest { + export interface ForgotPasswordRequest { Email: string; } - export class CreateGenreAlias { + export interface CreateGenreAlias { Title: string; } - export class GenreCreateRequest { + export interface GenreCreateRequest { Name: string; } - export class SystemStatus { + export interface SystemStatus { SystemUp: boolean; Version: string; } - export class OAuthRequest { + export interface OAuthRequest { Source: string; Token: string; } @@ -432,7 +432,7 @@ namespace nSwagger { PIntrest } - export class AddRatingRequest { + export interface AddRatingRequest { Notes: string; Rating: number; ThingId: string; @@ -443,7 +443,7 @@ namespace nSwagger { Book } - export class UpdateRatingRequest { + export interface UpdateRatingRequest { Notes: string; Rating: number; ThingId: string; @@ -454,19 +454,19 @@ namespace nSwagger { Book } - export class RegistrationConfirmRequest { + export interface RegistrationConfirmRequest { Email: string; PIN: string; } - export class CollectionResponseReservationResponseItem { - Items: ReservationResponseItem[]; + export interface CollectionResponseReservationResponseItem { + Items: Array; Next: string; Previous: string; TotalCount: number; } - export class ReservationResponseItem { + export interface ReservationResponseItem { Id: string; ReservedOn: string; Book: Book; @@ -480,10 +480,10 @@ namespace nSwagger { Book } - export class Book { + export interface Book { Author: string; Description: string; - Genres: Genre[]; + Genres: Array; GoodReadsId: string; GutenburgId: string; Id: string; @@ -505,7 +505,7 @@ namespace nSwagger { Active } - export class Genre { + export interface Genre { Id: number; Name: string; State: string; @@ -515,17 +515,17 @@ namespace nSwagger { Active } - export class ReserveRequest { + export interface ReserveRequest { ResourceId: string; } - export class PasswordResetRequest { + export interface PasswordResetRequest { Token: string; Password: string; PasswordConfirm: string; } - export class ResourceItem { + export interface ResourceItem { Book: BookItem; Type: string; } @@ -534,18 +534,18 @@ namespace nSwagger { Book } - export class ResourceCollection { + export interface ResourceCollection { Books: CollectionResponseBookItem; } - export class CollectionResponseRSVPItem { - Items: RSVPItem[]; + export interface CollectionResponseRSVPItem { + Items: Array; Next: string; Previous: string; TotalCount: number; } - export class RSVPItem { + export interface RSVPItem { ClubId: string; EndDate: string; EventId: string; @@ -564,7 +564,7 @@ namespace nSwagger { Maybe } - export class RSVPRequest { + export interface RSVPRequest { EventId: string; RSVP: string; } @@ -575,13 +575,13 @@ namespace nSwagger { Maybe } - export class SystemSettingItem { + export interface SystemSettingItem { EmailFrom: string; LootAffiliateCode: string; MaxClubsPerUser: number; } - export class EmailItem { + export interface EmailItem { HTML: string; PlainText: string; Subject: string; @@ -596,7 +596,7 @@ namespace nSwagger { EventUpdate } - export class TrendingFilterParameters { + export interface TrendingFilterParameters { AgeFilter: boolean; DateFilter: boolean; EndAgeRange: number; @@ -606,14 +606,14 @@ namespace nSwagger { StartDateRange: string; } - export class CollectionResponseClubGetUserResponse { - Items: ClubGetUserResponse[]; + export interface CollectionResponseClubGetUserResponse { + Items: Array; Next: string; Previous: string; TotalCount: number; } - export class ClubGetUserResponse { + export interface ClubGetUserResponse { RelationshipType: string; AddToBoxRule: string; BookCount: number; @@ -666,21 +666,21 @@ namespace nSwagger { MultiRead } - export class CollectionResponseRatingResponse { - Items: RatingResponse[]; + export interface CollectionResponseRatingResponse { + Items: Array; Next: string; Previous: string; TotalCount: number; } - export class CollectionResponseWishlistResponse { - Items: WishlistResponse[]; + export interface CollectionResponseWishlistResponse { + Items: Array; Next: string; Previous: string; TotalCount: number; } - export class WishlistResponse { + export interface WishlistResponse { Book: BookItem; Type: string; } @@ -689,28 +689,28 @@ namespace nSwagger { Book } - export class UserFindRequest { + export interface UserFindRequest { Query: string; } - export class CollectionResponseUserSearchResponse { - Items: UserSearchResponse[]; + export interface CollectionResponseUserSearchResponse { + Items: Array; Next: string; Previous: string; TotalCount: number; } - export class UserSearchResponse { + export interface UserSearchResponse { DisplayName: string; PhotoUrl: string; UserId: string; } - export class PhotoUpload { + export interface PhotoUpload { Base64Data: string; } - export class RegistrationRequest { + export interface RegistrationRequest { DayOfBirth: number; Email: string; FirstName: string; @@ -730,7 +730,7 @@ namespace nSwagger { Unspecified } - export class UserUpdateRequest { + export interface UserUpdateRequest { DayOfBirth: number; Email: string; FirstName: string; @@ -759,7 +759,7 @@ namespace nSwagger { Unspecified } - export class WishlistAdd { + export interface WishlistAdd { ResourceType: string; ThingId: string; } @@ -1290,9 +1290,9 @@ namespace nSwagger { Auth_Post(parameters: Auth_PostRequest): PromiseLike; Book_GetBookAdmin(parameters: Book_GetBookAdminRequest): PromiseLike; Book_GetRatings(parameters: Book_GetRatingsRequest): PromiseLike; - Book_GetTop10(parameters?: Book_GetTop10Request): PromiseLike; + Book_GetTop10(parameters?: Book_GetTop10Request): PromiseLike>; Book_Post(parameters: Book_PostRequest): PromiseLike; - Book_Get(parameters?: Book_GetRequest): PromiseLike; + Book_Get(parameters?: Book_GetRequest): PromiseLike>; Book_PostAdmin(parameters: Book_PostAdminRequest): PromiseLike; Book_PutBookUpdateAdmin(parameters: Book_PutBookUpdateAdminRequest): PromiseLike; BookRead_DeleteRead(parameters: BookRead_DeleteReadRequest): PromiseLike; @@ -1300,7 +1300,7 @@ namespace nSwagger { BookRead_Get(parameters?: BookRead_GetRequest): PromiseLike; BookRead_PostRead(parameters: BookRead_PostReadRequest): PromiseLike; Club_GetMembers(parameters: Club_GetMembersRequest): PromiseLike; - Club_GetTop10(parameters: Club_GetTop10Request): PromiseLike; + Club_GetTop10(parameters: Club_GetTop10Request): PromiseLike>; Club_PostChangeUsersRole(parameters: Club_PostChangeUsersRoleRequest): PromiseLike; Club_PostRemoveUserFromClub(parameters: Club_PostRemoveUserFromClubRequest): PromiseLike; Club_PostSearch(parameters: Club_PostSearchRequest): PromiseLike; @@ -1327,7 +1327,7 @@ namespace nSwagger { Genres_PostAlias(parameters: Genres_PostAliasRequest): PromiseLike; Genres_Delete(parameters: Genres_DeleteRequest): PromiseLike; Genres_Put(parameters: Genres_PutRequest): PromiseLike; - Genres_Get(parameters?: Genres_GetRequest): PromiseLike; + Genres_Get(parameters?: Genres_GetRequest): PromiseLike>; Genres_Post(parameters: Genres_PostRequest): PromiseLike; Health_Get(): PromiseLike; Logout_Post(): PromiseLike; @@ -1364,8 +1364,8 @@ namespace nSwagger { System_GetSystemEmail(parameters: System_GetSystemEmailRequest): PromiseLike; System_GetSystemEmails(): PromiseLike; System_PutSystemEmail(parameters: System_PutSystemEmailRequest): PromiseLike; - Trending_GetClubTrending(parameters: Trending_GetClubTrendingRequest): PromiseLike; - Trending_GetTrending(parameters?: Trending_GetTrendingRequest): PromiseLike; + Trending_GetClubTrending(parameters: Trending_GetClubTrendingRequest): PromiseLike>; + Trending_GetTrending(parameters?: Trending_GetTrendingRequest): PromiseLike>; User_DeleteClubInvite(parameters: User_DeleteClubInviteRequest): PromiseLike; User_PutEventInvite(parameters: User_PutEventInviteRequest): PromiseLike; User_DeleteEventInvite(parameters: User_DeleteEventInviteRequest): PromiseLike; @@ -1375,7 +1375,7 @@ namespace nSwagger { User_GetEvents(parameters?: User_GetEventsRequest): PromiseLike; User_GetInvites(parameters?: User_GetInvitesRequest): PromiseLike; User_GetMyEventInvite(parameters?: User_GetMyEventInviteRequest): PromiseLike; - User_GetMyReservations(parameters?: User_GetMyReservationsRequest): PromiseLike; + User_GetMyReservations(parameters?: User_GetMyReservationsRequest): PromiseLike>; User_GetRatings(parameters: User_GetRatingsRequest): PromiseLike; User_GetRatings(parameters?: User_GetRatingsRequest): PromiseLike; User_GetReadBooks(parameters: User_GetReadBooksRequest): PromiseLike; diff --git a/examples/TS-Examples/devconf.ts b/examples/TS-Examples/devconf.ts new file mode 100644 index 0000000..64b1649 --- /dev/null +++ b/examples/TS-Examples/devconf.ts @@ -0,0 +1,56 @@ +// This file was autogenerated by nSwagger 0.0.2 - changes made to it maybe lost if nSwagger is run again +namespace nSwagger { + export module DevConfRatings { + export interface GetRatings { + Email: string; + } + + export interface RatingSession { + Comment: string; + Order: number; + Rating: number; + SessionId: number; + } + + export interface Rating { + Email: string; + Session1: RatingSession; + Session2: RatingSession; + Session3: RatingSession; + Session4: RatingSession; + Session5: RatingSession; + Session6: RatingSession; + Session7: RatingSession; + Session8: RatingSession; + } + + export interface TimeSlot { + End: string; + Order: number; + Sessions: Array; + Start: string; + } + + export interface Session { + Id: number; + Presenter: string; + Title: string; + Track: string; + } + + export interface Rating_PostGetRatingRequest { + request: GetRatings; + } + + export interface Rating_PostAddRatingRequest { + rating: Rating; + } + + export interface API { + setToken(value: string, headerOrQueryName: string, isQuery: boolean): void; + Rating_PostGetRating(parameters: Rating_PostGetRatingRequest): PromiseLike>; + Rating_PostAddRating(parameters: Rating_PostAddRatingRequest): PromiseLike; + Session_GetSessions(): PromiseLike>; + } + } +} diff --git a/examples/TS-Examples/kiosk.ts b/examples/TS-Examples/kiosk.ts index b356f9b..018d7db 100644 --- a/examples/TS-Examples/kiosk.ts +++ b/examples/TS-Examples/kiosk.ts @@ -1,12 +1,12 @@ -// This file was autogenerated by nSwagger 0.0.1 - changes made to it maybe lost if nSwagger is run again +// This file was autogenerated by nSwagger 0.0.2 - changes made to it maybe lost if nSwagger is run again namespace nSwagger { export module API { - export class SignupRequest { + export interface SignupRequest { Email: string; Password: string; } - export class AdminResponse { + export interface AdminResponse { Email: string; Id: string; Role: string; @@ -26,30 +26,30 @@ namespace nSwagger { WaitingForPinConfirmation } - export class UpdateCartItemsRequest { - CartItems: AddCartItemRequest[]; + export interface UpdateCartItemsRequest { + CartItems: Array; } - export class AddCartItemRequest { + export interface AddCartItemRequest { CartItem: number; Item: number; Quantity: number; } - export class CartResponse { - CartItems: CartItemResponse[]; + export interface CartResponse { + CartItems: Array; Id: number; OrderNumber: string; } - export class CartItemResponse { + export interface CartItemResponse { Id: number; Item: ItemResponse; Price: number; Quantity: number; } - export class ItemResponse { + export interface ItemResponse { Description: string; Id: number; Image: string; @@ -57,12 +57,12 @@ namespace nSwagger { Title: string; } - export class MenuCategoryRequest { + export interface MenuCategoryRequest { ImageId: string; Title: string; } - export class CategoryResponse { + export interface CategoryResponse { Id: number; ImageId: string; State: string; @@ -74,29 +74,29 @@ namespace nSwagger { Disabled } - export class VerifyUserRequest { + export interface VerifyUserRequest { Email: string; Pin: string; } - export class ItemRequest { + export interface ItemRequest { Description: string; ImageId: string; Price: number; Title: string; } - export class ResetPasswordRequest { + export interface ResetPasswordRequest { Password: string; Pin: string; } - export class LoginRequest { + export interface LoginRequest { Email: string; Password: string; } - export class LoginResponse { + export interface LoginResponse { Role: string; Token: string; } @@ -108,10 +108,10 @@ namespace nSwagger { Service } - export class OrderResponse { + export interface OrderResponse { Date: string; Id: number; - Items: OrderItemResponse[]; + Items: Array; OrderId: string; State: string; TotalPrice: number; @@ -126,7 +126,7 @@ namespace nSwagger { Abandoned } - export class OrderItemResponse { + export interface OrderItemResponse { Id: number; item: ItemResponse; OrderId: number; @@ -134,7 +134,7 @@ namespace nSwagger { Quantity: number; } - export class ReportingRequest { + export interface ReportingRequest { EndDate: string; OrderStates: string; StartDate: string; @@ -149,24 +149,24 @@ namespace nSwagger { Abandoned } - export class TradingHourResponse { + export interface TradingHourResponse { Closing: string; Date: string; Id: number; Openning: string; } - export class TradingHoursRequest { + export interface TradingHoursRequest { Closing: string; Date: string; Openning: string; } - export class UpdateUserRequest { + export interface UpdateUserRequest { Password: string; } - export class UpdateUserAdminRequest { + export interface UpdateUserAdminRequest { Id: string; Email: string; State: string; @@ -329,7 +329,7 @@ namespace nSwagger { Admin_PostNewAdmin(parameters: Admin_PostNewAdminRequest): PromiseLike; Admin_PostNewKitchen(parameters: Admin_PostNewKitchenRequest): PromiseLike; Admin_DeleteAdmin(parameters: Admin_DeleteAdminRequest): PromiseLike; - Admin_GetAdmins(): PromiseLike; + Admin_GetAdmins(): PromiseLike>; Cart_Delete(parameters: Cart_DeleteRequest): PromiseLike; Cart_PostChangeOrderState(parameters: Cart_PostChangeOrderStateRequest): PromiseLike; Cart_PutCartItems(parameters: Cart_PutCartItemsRequest): PromiseLike; @@ -338,10 +338,10 @@ namespace nSwagger { Category_DeleteMenuCategory(parameters: Category_DeleteMenuCategoryRequest): PromiseLike; Category_EnableMenuCategory(parameters: Category_EnableMenuCategoryRequest): PromiseLike; Category_PutAdminMenuCategory(parameters: Category_PutAdminMenuCategoryRequest): PromiseLike; - Category_GetCategories(): PromiseLike; + Category_GetCategories(): PromiseLike>; Category_PostAdminMenuCategory(parameters: Category_PostAdminMenuCategoryRequest): PromiseLike; ConfirmUser_Post(parameters: ConfirmUser_PostRequest): PromiseLike; - Item_GetMenuItems(parameters: Item_GetMenuItemsRequest): PromiseLike; + Item_GetMenuItems(parameters: Item_GetMenuItemsRequest): PromiseLike>; Item_PutEnableMenuItem(parameters: Item_PutEnableMenuItemRequest): PromiseLike; Item_PutItem(parameters: Item_PutItemRequest): PromiseLike; Item_DeleteMenuItem(parameters: Item_DeleteMenuItemRequest): PromiseLike; @@ -350,13 +350,13 @@ namespace nSwagger { Login_PostResetPassword(parameters: Login_PostResetPasswordRequest): PromiseLike; Login_PostLogin(parameters: Login_PostLoginRequest): PromiseLike; Logout_PostLogout(): PromiseLike; - Order_GetOrdersByState(parameters: Order_GetOrdersByStateRequest): PromiseLike; - Order_GetTodayOrders(): PromiseLike; - Order_GetUserOrderHistory(parameters?: Order_GetUserOrderHistoryRequest): PromiseLike; + Order_GetOrdersByState(parameters: Order_GetOrdersByStateRequest): PromiseLike>; + Order_GetTodayOrders(): PromiseLike>; + Order_GetUserOrderHistory(parameters?: Order_GetUserOrderHistoryRequest): PromiseLike>; Reporting_Post(parameters: Reporting_PostRequest): PromiseLike; Signup_PostResendPin(parameters: Signup_PostResendPinRequest): PromiseLike; Signup_PostSignup(parameters: Signup_PostSignupRequest): PromiseLike; - TradingHours_GetTradingHours(): PromiseLike; + TradingHours_GetTradingHours(): PromiseLike>; TradingHours_PostAddTradingHours(parameters: TradingHours_PostAddTradingHoursRequest): PromiseLike; TradingHours_PutUpdateTradingHours(parameters: TradingHours_PutUpdateTradingHoursRequest): PromiseLike; User_PutDisableAdmin(parameters: User_PutDisableAdminRequest): PromiseLike; @@ -364,7 +364,7 @@ namespace nSwagger { User_PutUser(parameters: User_PutUserRequest): PromiseLike; User_PutUserAdmin(parameters: User_PutUserAdminRequest): PromiseLike; User_PutUserRole(parameters: User_PutUserRoleRequest): PromiseLike; - User_GetAllUsers(): PromiseLike; + User_GetAllUsers(): PromiseLike>; User_GetUser(parameters: User_GetUserRequest): PromiseLike; } } diff --git a/examples/TS-Examples/petstore-expanded.ts b/examples/TS-Examples/petstore-expanded.ts index 806095a..11a1ab6 100644 --- a/examples/TS-Examples/petstore-expanded.ts +++ b/examples/TS-Examples/petstore-expanded.ts @@ -1,21 +1,21 @@ -// This file was autogenerated by nSwagger 0.0.1 - changes made to it maybe lost if nSwagger is run again +// This file was autogenerated by nSwagger 0.0.2 - changes made to it maybe lost if nSwagger is run again namespace nSwagger { export module SwaggerPetstore { - export class Pet { + export interface Pet { } - export class NewPet { + export interface NewPet { name: string; tag: string; } - export class Error { + export interface Error { code: number; message: string; } export interface findPetsRequest { - tags?: string[]; + tags?: Array; limit?: number; } @@ -33,7 +33,7 @@ namespace nSwagger { export interface API { setToken(value: string, headerOrQueryName: string, isQuery: boolean): void; - findPets(parameters?: findPetsRequest): PromiseLike; + findPets(parameters?: findPetsRequest): PromiseLike>; addPet(parameters: addPetRequest): PromiseLike; deletePet(parameters: deletePetRequest): PromiseLike; findpetbyid(parameters: findpetbyidRequest): PromiseLike; diff --git a/examples/TS-Examples/petstore-minimal.ts b/examples/TS-Examples/petstore-minimal.ts index fd47b97..06a4ee2 100644 --- a/examples/TS-Examples/petstore-minimal.ts +++ b/examples/TS-Examples/petstore-minimal.ts @@ -1,7 +1,7 @@ -// This file was autogenerated by nSwagger 0.0.1 - changes made to it maybe lost if nSwagger is run again +// This file was autogenerated by nSwagger 0.0.2 - changes made to it maybe lost if nSwagger is run again namespace nSwagger { export module SwaggerPetstore { - export class Pet { + export interface Pet { id: number; name: string; tag: string; @@ -9,7 +9,7 @@ namespace nSwagger { export interface API { setToken(value: string, headerOrQueryName: string, isQuery: boolean): void; - getPets(): PromiseLike; + getPets(): PromiseLike>; } } } diff --git a/examples/TS-Examples/petstore-simple.ts b/examples/TS-Examples/petstore-simple.ts index c7084ce..bc574ea 100644 --- a/examples/TS-Examples/petstore-simple.ts +++ b/examples/TS-Examples/petstore-simple.ts @@ -1,22 +1,22 @@ -// This file was autogenerated by nSwagger 0.0.1 - changes made to it maybe lost if nSwagger is run again +// This file was autogenerated by nSwagger 0.0.2 - changes made to it maybe lost if nSwagger is run again namespace nSwagger { export module SwaggerPetstore { - export class Pet { + export interface Pet { id: number; name: string; tag: string; } - export class PetInput { + export interface PetInput { } - export class ErrorModel { + export interface ErrorModel { code: number; message: string; } export interface findPetsRequest { - tags?: string[]; + tags?: Array; limit?: number; } @@ -34,7 +34,7 @@ namespace nSwagger { export interface API { setToken(value: string, headerOrQueryName: string, isQuery: boolean): void; - findPets(parameters?: findPetsRequest): PromiseLike; + findPets(parameters?: findPetsRequest): PromiseLike>; addPet(parameters: addPetRequest): PromiseLike; deletePet(parameters: deletePetRequest): PromiseLike; findPetById(parameters: findPetByIdRequest): PromiseLike; diff --git a/examples/TS-Examples/petstore-with-external-docs.ts b/examples/TS-Examples/petstore-with-external-docs.ts index fd84f32..9b73b74 100644 --- a/examples/TS-Examples/petstore-with-external-docs.ts +++ b/examples/TS-Examples/petstore-with-external-docs.ts @@ -1,22 +1,22 @@ -// This file was autogenerated by nSwagger 0.0.1 - changes made to it maybe lost if nSwagger is run again +// This file was autogenerated by nSwagger 0.0.2 - changes made to it maybe lost if nSwagger is run again namespace nSwagger { export module SwaggerPetstore { - export class Pet { + export interface Pet { id: number; name: string; tag: string; } - export class NewPet { + export interface NewPet { } - export class ErrorModel { + export interface ErrorModel { code: number; message: string; } export interface findPetsRequest { - tags?: string[]; + tags?: Array; limit?: number; } @@ -34,7 +34,7 @@ namespace nSwagger { export interface API { setToken(value: string, headerOrQueryName: string, isQuery: boolean): void; - findPets(parameters?: findPetsRequest): PromiseLike; + findPets(parameters?: findPetsRequest): PromiseLike>; addPet(parameters: addPetRequest): PromiseLike; deletePet(parameters: deletePetRequest): PromiseLike; findPetById(parameters: findPetByIdRequest): PromiseLike; diff --git a/examples/TS-Examples/petstore.ts b/examples/TS-Examples/petstore.ts index 2b8bb08..17d99aa 100644 --- a/examples/TS-Examples/petstore.ts +++ b/examples/TS-Examples/petstore.ts @@ -1,20 +1,20 @@ -// This file was autogenerated by nSwagger 0.0.1 - changes made to it maybe lost if nSwagger is run again +// This file was autogenerated by nSwagger 0.0.2 - changes made to it maybe lost if nSwagger is run again namespace nSwagger { export module SwaggerPetstore { - export class Pet { + export interface Pet { id: number; name: string; tag: string; } - export class Error { + export interface Error { code: number; message: string; } export interface API { setToken(value: string, headerOrQueryName: string, isQuery: boolean): void; - getPets(): PromiseLike; + getPets(): PromiseLike>; } } } diff --git a/examples/TS-Examples/s2b.ts b/examples/TS-Examples/s2b.ts index 91d1400..fb6332b 100644 --- a/examples/TS-Examples/s2b.ts +++ b/examples/TS-Examples/s2b.ts @@ -1,7 +1,7 @@ -// This file was autogenerated by nSwagger 0.0.1 - changes made to it maybe lost if nSwagger is run again +// This file was autogenerated by nSwagger 0.0.2 - changes made to it maybe lost if nSwagger is run again namespace nSwagger { export module Portal { - export class AdminResponse { + export interface AdminResponse { Email: string; FirstName: string; Id: string; @@ -16,41 +16,41 @@ namespace nSwagger { Disabled } - export class UpdateAdminRequest { + export interface UpdateAdminRequest { FirstName: string; LastName: string; } - export class FilterParameters { + export interface FilterParameters { Skip: number; Top: number; } - export class CollectionResponseAdminResponse { - Items: AdminResponse[]; + export interface CollectionResponseAdminResponse { + Items: Array; Next: string; Previous: string; TotalCount: number; } - export class NewAdminRequest { + export interface NewAdminRequest { Email: string; FirstName: string; LastName: string; } - export class CalendarShareRequest { + export interface CalendarShareRequest { Email: string; } - export class CollectionResponseCalendarResponse { - Items: CalendarResponse[]; + export interface CollectionResponseCalendarResponse { + Items: Array; Next: string; Previous: string; TotalCount: number; } - export class CalendarResponse { + export interface CalendarResponse { EndDate: string; Id: number; StartDate: string; @@ -68,7 +68,7 @@ namespace nSwagger { Exam } - export class User { + export interface User { AmountLastStipendReceived: number; City: string; DateLastStipendReceived: string; @@ -131,11 +131,11 @@ namespace nSwagger { Employeed } - export class HostEmployer { + export interface HostEmployer { Id: number; Name: string; State: string; - Students: User[]; + Students: Array; } export enum HostEmployerState { @@ -143,7 +143,7 @@ namespace nSwagger { Disabled } - export class CalendarRequest { + export interface CalendarRequest { EndDate: string; EventId: number; StartDate: string; @@ -155,14 +155,14 @@ namespace nSwagger { Exam } - export class CollectionResponseCourseResponse { - Items: CourseResponse[]; + export interface CollectionResponseCourseResponse { + Items: Array; Next: string; Previous: string; TotalCount: number; } - export class CourseResponse { + export interface CourseResponse { Code: string; Id: number; Name: string; @@ -174,40 +174,40 @@ namespace nSwagger { Disabled } - export class CourseRequest { + export interface CourseRequest { Code: string; Name: string; } - export class CollectionResponseDroppedOutResponse { - Items: DroppedOutResponse[]; + export interface CollectionResponseDroppedOutResponse { + Items: Array; Next: string; Previous: string; TotalCount: number; } - export class DroppedOutResponse { + export interface DroppedOutResponse { AmountLastStipendRecieved: number; DateLastStipendRecieved: string; DropOutReason: string; DroppedOutDate: string; } - export class DroppedOutRequest { + export interface DroppedOutRequest { AmountLastStipendRecieved: number; DateLastStipendRecieved: string; DropOutReason: string; DroppedOutDate: string; } - export class CollectionResponseExamResponse { - Items: ExamResponse[]; + export interface CollectionResponseExamResponse { + Items: Array; Next: string; Previous: string; TotalCount: number; } - export class ExamResponse { + export interface ExamResponse { Code: string; ExamName: string; Passed: string; @@ -226,19 +226,19 @@ namespace nSwagger { Disabled } - export class ExamRequest { + export interface ExamRequest { Code: string; Name: string; } - export class CollectionResponseFeedbackResponse { - Items: FeedbackResponse[]; + export interface CollectionResponseFeedbackResponse { + Items: Array; Next: string; Previous: string; TotalCount: number; } - export class FeedbackResponse { + export interface FeedbackResponse { Comment: string; RepliedAt: string; RepliedBy: User; @@ -251,7 +251,7 @@ namespace nSwagger { Pending } - export class StudentResponse { + export interface StudentResponse { City: string; Email: string; FirstName: string; @@ -285,18 +285,18 @@ namespace nSwagger { Employeed } - export class FeedbackRequest { + export interface FeedbackRequest { Comment: string; } - export class CollectionResponseFurtherEmploymentResponse { - Items: FurtherEmploymentResponse[]; + export interface CollectionResponseFurtherEmploymentResponse { + Items: Array; Next: string; Previous: string; TotalCount: number; } - export class FurtherEmploymentResponse { + export interface FurtherEmploymentResponse { FurtherEmploymentCompanyName: string; FurtherEmploymentEmail: string; FurtherEmploymentManagerName: string; @@ -306,7 +306,7 @@ namespace nSwagger { Student: StudentResponse; } - export class FurtherEmploymentRequest { + export interface FurtherEmploymentRequest { CompanyName: string; Email: string; ManagerName: string; @@ -315,7 +315,7 @@ namespace nSwagger { StartDate: string; } - export class HostEmployerResponse { + export interface HostEmployerResponse { Name: string; State: string; } @@ -325,13 +325,13 @@ namespace nSwagger { Disabled } - export class HostEmployerRequest { + export interface HostEmployerRequest { Name: string; } - export class TrainingProviderResponse { - Courses: CourseResponse[]; - Exams: ExamResponse[]; + export interface TrainingProviderResponse { + Courses: Array; + Exams: Array; Name: string; State: string; } @@ -341,28 +341,28 @@ namespace nSwagger { Disabled } - export class CollectionResponseHostEmployerResponse { - Items: HostEmployerResponse[]; + export interface CollectionResponseHostEmployerResponse { + Items: Array; Next: string; Previous: string; TotalCount: number; } - export class ConfirmPasswordResetRequest { + export interface ConfirmPasswordResetRequest { Password: string; Token: string; } - export class BeginPasswordResetRequest { + export interface BeginPasswordResetRequest { Email: string; } - export class LoginRequest { + export interface LoginRequest { Email: string; Password: string; } - export class LoginResponse { + export interface LoginResponse { Role: string; Token: string; } @@ -372,7 +372,7 @@ namespace nSwagger { Admin } - export class RewardResponse { + export interface RewardResponse { Description: string; Id: number; ImageId: string; @@ -390,7 +390,7 @@ namespace nSwagger { Disable } - export class RewardRequest { + export interface RewardRequest { Description: string; ImageId: string; Name: string; @@ -401,40 +401,40 @@ namespace nSwagger { SignedUp } - export class CollectionResponseRewardResponse { - Items: RewardResponse[]; + export interface CollectionResponseRewardResponse { + Items: Array; Next: string; Previous: string; TotalCount: number; } - export class CollectionResponseClaimedRewardsResponse { - Items: ClaimedRewardsResponse[]; + export interface CollectionResponseClaimedRewardsResponse { + Items: Array; Next: string; Previous: string; TotalCount: number; } - export class ClaimedRewardsResponse { + export interface ClaimedRewardsResponse { Claimed: string; Id: number; Reward: RewardResponse; Student: StudentResponse; } - export class CollectionResponseTrainingProviderResponse { - Items: TrainingProviderResponse[]; + export interface CollectionResponseTrainingProviderResponse { + Items: Array; Next: string; Previous: string; TotalCount: number; } - export class AddStudentsToExamsRequest { + export interface AddStudentsToExamsRequest { ExamId: number; TrainingProviderId: number; } - export class StudentsRequest { + export interface StudentsRequest { City: string; Email: string; FirstName: string; @@ -450,32 +450,32 @@ namespace nSwagger { Province: string; } - export class CollectionResponseStudentResponse { - Items: StudentResponse[]; + export interface CollectionResponseStudentResponse { + Items: Array; Next: string; Previous: string; TotalCount: number; } - export class CreateStudentRequest { + export interface CreateStudentRequest { Email: string; } - export class AddCourseToTrainingProviderRequest { + export interface AddCourseToTrainingProviderRequest { CourseId: number; TrainingProviderId: number; } - export class TrainingProviderRequest { + export interface TrainingProviderRequest { Name: string; } - export class EditCourseToTrainingProvidersRequest { + export interface EditCourseToTrainingProvidersRequest { CourseId: number; TrainingProvidersId: number; } - export class ResetPasswordRequest { + export interface ResetPasswordRequest { Password: string; } @@ -780,9 +780,9 @@ namespace nSwagger { export interface API { setToken(value: string, headerOrQueryName: string, isQuery: boolean): void; Admins_GetAdmin(parameters: Admins_GetAdminRequest): PromiseLike; - Admins_PutUpdateAdmin(parameters: Admins_PutUpdateAdminRequest): PromiseLike; + Admins_PutUpdateAdmin(parameters: Admins_PutUpdateAdminRequest): PromiseLike>; Admins_GetAdmins(parameters?: Admins_GetAdminsRequest): PromiseLike; - Admins_PostAdmins(parameters: Admins_PostAdminsRequest): PromiseLike; + Admins_PostAdmins(parameters: Admins_PostAdminsRequest): PromiseLike>; Calendar_DeleteCalendarEntry(parameters: Calendar_DeleteCalendarEntryRequest): PromiseLike; Calendar_PostShareCalendar(parameters: Calendar_PostShareCalendarRequest): PromiseLike; Calendar_GetCalendar(parameters?: Calendar_GetCalendarRequest): PromiseLike; @@ -814,7 +814,7 @@ namespace nSwagger { HostEmployer_PutDisableHostEmployer(parameters: HostEmployer_PutDisableHostEmployerRequest): PromiseLike; HostEmployer_PutEnableHostEmployer(parameters: HostEmployer_PutEnableHostEmployerRequest): PromiseLike; HostEmployer_GetHostEmployer(parameters: HostEmployer_GetHostEmployerRequest): PromiseLike; - HostEmployer_PutHostEmployer(parameters: HostEmployer_PutHostEmployerRequest): PromiseLike; + HostEmployer_PutHostEmployer(parameters: HostEmployer_PutHostEmployerRequest): PromiseLike>; HostEmployer_GetHostEmployers(parameters?: HostEmployer_GetHostEmployersRequest): PromiseLike; HostEmployer_PostAddHostEmployer(parameters: HostEmployer_PostAddHostEmployerRequest): PromiseLike; Login_PostConfirmPasswordReset(parameters: Login_PostConfirmPasswordResetRequest): PromiseLike; @@ -838,7 +838,7 @@ namespace nSwagger { TrainingProviders_PostAddCourseToTrainingProvider(parameters: TrainingProviders_PostAddCourseToTrainingProviderRequest): PromiseLike; TrainingProviders_PutDisableTrainingProvider(parameters: TrainingProviders_PutDisableTrainingProviderRequest): PromiseLike; TrainingProviders_GetTrainingProvider(parameters: TrainingProviders_GetTrainingProviderRequest): PromiseLike; - TrainingProviders_PutTrainingProviders(parameters: TrainingProviders_PutTrainingProvidersRequest): PromiseLike; + TrainingProviders_PutTrainingProviders(parameters: TrainingProviders_PutTrainingProvidersRequest): PromiseLike>; TrainingProviders_GetTrainingProviders(parameters?: TrainingProviders_GetTrainingProvidersRequest): PromiseLike; TrainingProviders_PostTrainingProviders(parameters: TrainingProviders_PostTrainingProvidersRequest): PromiseLike; TrainingProviders_PutEditCoursesToTrainingProviders(parameters: TrainingProviders_PutEditCoursesToTrainingProvidersRequest): PromiseLike; diff --git a/examples/devconf.json b/examples/devconf.json new file mode 100644 index 0000000..1889284 --- /dev/null +++ b/examples/devconf.json @@ -0,0 +1,153 @@ +{ + "swagger": "2.0", + "info": { + "version": "v1", + "title": "DevConfRatings" + }, + "host": "localhost:24110", + "schemes": [ "https" ], + "paths": { + "/api/rating/history": { + "post": { + "tags": [ "Rating" ], + "summary": "Gets previously entered reviews", + "operationId": "Rating_PostGetRating", + "consumes": [ "application/json", "text/json", "application/xml", "text/xml", "application/x-www-form-urlencoded" ], + "produces": [ "application/json", "text/json", "application/xml", "text/xml" ], + "parameters": [ + { + "name": "request", + "in": "body", + "description": "email or token for lookup", + "required": true, + "schema": { "$ref": "#/definitions/GetRatings" } + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "array", + "items": { "$ref": "#/definitions/RatingSession" } + } + }, + "400": { "description": "Invalud email/token" }, + "404": { "description": "User not found" } + }, + "deprecated": false + } + }, + "/api/Rating": { + "post": { + "tags": [ "Rating" ], + "summary": "Used to add a rating or update a rating in the system", + "operationId": "Rating_PostAddRating", + "consumes": [ "application/json", "text/json", "application/xml", "text/xml", "application/x-www-form-urlencoded" ], + "produces": [ "application/json", "text/json", "application/xml", "text/xml" ], + "parameters": [ + { + "name": "rating", + "in": "body", + "description": "The rating value", + "required": true, + "schema": { "$ref": "#/definitions/Rating" } + } + ], + "responses": { + "400": { "description": "Data provided is wrong" }, + "401": { "description": "User account is disabled" }, + "204": { + "description": "Success", + "schema": { "type": "string" } + } + }, + "deprecated": false + } + }, + "/api/Session": { + "get": { + "tags": [ "Session" ], + "summary": "Gets all the sessions", + "operationId": "Session_GetSessions", + "consumes": [ ], + "produces": [ "application/json", "text/json", "application/xml", "text/xml" ], + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "array", + "items": { "$ref": "#/definitions/TimeSlot" } + } + } + }, + "deprecated": false + } + } + }, + "definitions": { + "GetRatings": { + "type": "object", + "properties": { "Email": { "type": "string" } } + }, + "RatingSession": { + "type": "object", + "properties": { + "Comment": { "type": "string" }, + "Order": { + "format": "int32", + "type": "integer" + }, + "Rating": { + "format": "int32", + "type": "integer" + }, + "SessionId": { + "format": "int32", + "type": "integer" + } + } + }, + "Rating": { + "type": "object", + "properties": { + "Email": { "type": "string" }, + "Session1": { "$ref": "#/definitions/RatingSession" }, + "Session2": { "$ref": "#/definitions/RatingSession" }, + "Session3": { "$ref": "#/definitions/RatingSession" }, + "Session4": { "$ref": "#/definitions/RatingSession" }, + "Session5": { "$ref": "#/definitions/RatingSession" }, + "Session6": { "$ref": "#/definitions/RatingSession" }, + "Session7": { "$ref": "#/definitions/RatingSession" }, + "Session8": { "$ref": "#/definitions/RatingSession" } + } + }, + "TimeSlot": { + "type": "object", + "properties": { + "End": { "type": "string" }, + "Order": { + "format": "int32", + "type": "integer", + "readOnly": true + }, + "Sessions": { + "type": "array", + "items": { "$ref": "#/definitions/Session" } + }, + "Start": { "type": "string" } + } + }, + "Session": { + "type": "object", + "properties": { + "Id": { + "format": "int32", + "type": "integer" + }, + "Presenter": { "type": "string" }, + "Title": { "type": "string" }, + "Track": { "type": "string" } + } + } + } +} diff --git a/nSwagger/Configuration.cs b/nSwagger/Configuration.cs index afde905..c2ddbd6 100644 --- a/nSwagger/Configuration.cs +++ b/nSwagger/Configuration.cs @@ -39,7 +39,7 @@ public Configuration() public string Namespace { get; set; } = "nSwagger"; - public string nSwaggerVersion { get; } = "0.0.1"; + public string nSwaggerVersion { get; } = "0.0.2"; public bool SaveSettings { get; set; } diff --git a/nSwagger/TypeScriptGenerator.cs b/nSwagger/TypeScriptGenerator.cs index 6745bb8..f108db3 100644 --- a/nSwagger/TypeScriptGenerator.cs +++ b/nSwagger/TypeScriptGenerator.cs @@ -75,7 +75,7 @@ public string ItemTypeCleaner(Item item) if (item.Type.Equals("array", StringComparison.OrdinalIgnoreCase)) { - return "[]"; + return "Array"; } return CleanClassName(item.Type); @@ -197,7 +197,56 @@ private void AddAPIRequest(CoderStringBuilder output, Operation operation) } } - private void AddClass(CoderStringBuilder output, string sourceName, Property[] properties) + private void AddParameterInterface(CoderStringBuilder output, string sourceName, Parameter[] parameters) + { + var name = CleanClassName(sourceName); + if (existingInterfaces.Contains(name)) + { + return; + } + + existingInterfaces.Add(name); + + output.AppendLine($"export interface {name} {{"); + output.Indent(); + foreach (var parameter in parameters) + { + var propertyName = parameter.Name; + if (!parameter.Required) + { + propertyName += "?"; + } + + var propertyType = "any"; + var bodyParameter = parameter as BodyParameter; + if (bodyParameter != null) + { + propertyType = SchemaTypeCleaner(bodyParameter.Schema); + } + + var otherParameter = parameter as OtherParameter; + if (otherParameter != null) + { + var arrayParameter = parameter as OtherArrayParameter; + if (arrayParameter != null) + { + propertyType = $"Array<{CleanClassName(arrayParameter.Items[0].Type)}>"; + } + else + { + propertyType = CleanClassName(otherParameter.Type); + } + } + + output.AppendLine($"{propertyName}: {propertyType};"); + } + + output.Outdent(); + output.AppendLine("}"); + output.AppendLine(); + } + + private void AddTypes(CoderStringBuilder output, string sourceName, Property[] properties) { var enums = new List(); var name = CleanClassName(sourceName); @@ -208,7 +257,7 @@ private void AddClass(CoderStringBuilder output, string sourceName, Property[] p existingInterfaces.Add(name); - output.AppendLine($"export class {name} {{"); + output.AppendLine($"export interface {name} {{"); output.Indent(); if (properties != null) { @@ -260,55 +309,6 @@ private void AddClass(CoderStringBuilder output, string sourceName, Property[] p } } - private void AddParameterInterface(CoderStringBuilder output, string sourceName, Parameter[] parameters) - { - var name = CleanClassName(sourceName); - if (existingInterfaces.Contains(name)) - { - return; - } - - existingInterfaces.Add(name); - - output.AppendLine($"export interface {name} {{"); - output.Indent(); - foreach (var parameter in parameters) - { - var propertyName = parameter.Name; - if (!parameter.Required) - { - propertyName += "?"; - } - - var propertyType = "any"; - var bodyParameter = parameter as BodyParameter; - if (bodyParameter != null) - { - propertyType = SchemaTypeCleaner(bodyParameter.Schema); - } - - var otherParameter = parameter as OtherParameter; - if (otherParameter != null) - { - var arrayParameter = parameter as OtherArrayParameter; - if (arrayParameter != null) - { - propertyType = CleanClassName(arrayParameter.Items[0].Type) + "[]"; - } - else - { - propertyType = CleanClassName(otherParameter.Type); - } - } - - output.AppendLine($"{propertyName}: {propertyType};"); - } - - output.Outdent(); - output.AppendLine("}"); - output.AppendLine(); - } - private string CamelCase(IEnumerable segments) { if (segments.Count() == 1) @@ -382,7 +382,7 @@ private void Process(CoderStringBuilder output, Specification specification) output.Indent(); foreach (var defination in specification.Definations) { - AddClass(output, defination.Name, defination.Properties); + AddTypes(output, defination.Name, defination.Properties); } foreach (var path in specification.Paths) @@ -429,15 +429,15 @@ private string PropertyTypeCleaner(Property property) { if (string.IsNullOrWhiteSpace(property.ArrayItemType)) { - return "any[]"; + return "Array"; } if (property.ArrayItemType.Contains('/')) { - return RefToClass(property.ArrayItemType) + "[]"; + return $"Array<{RefToClass(property.ArrayItemType)}>"; } - return CleanClassName(property.ArrayItemType) + "[]"; + return $"Array<{CleanClassName(property.ArrayItemType)}>"; } return CleanClassName(property.Type); @@ -454,13 +454,10 @@ private string SchemaTypeCleaner(Schema property) if (property.Type.Equals("array", StringComparison.OrdinalIgnoreCase)) { - var array = "[]"; + var array = "Array"; if (property.Items != null && property.Items.Length == 1) { - array = CleanClassName(ItemTypeCleaner(property.Items[0]) + "[]"); - } - else { - array = "any[]"; + array = $"Array<{CleanClassName(ItemTypeCleaner(property.Items[0]))}>"; } return array;