-
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #172 from Noblix/main
Allow for custom relative output path in .refitter
- Loading branch information
Showing
7 changed files
with
178 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
...Refitter.SourceGenerator.Tests/AdditionalFiles/SwaggerPetstoreCustomOutputFolder.refitter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"openApiPath": "../Resources/V3/SwaggerPetstore.json", | ||
"namespace": "Refitter.Tests.CustomGenerated", | ||
"output": "../CustomGenerated", | ||
"generateContracts": false, | ||
"additionalNamespaces": ["Refitter.Tests.AdditionalFiles.SingeInterface"], | ||
"naming": { | ||
"useOpenApiTitle": false, | ||
"interfaceName": "ApiInCustomGeneratedFolder" | ||
} | ||
} |
131 changes: 131 additions & 0 deletions
131
src/Refitter.SourceGenerator.Tests/CustomGenerated/SwaggerPetstoreCustomOutputFolder.g.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
// <auto-generated> | ||
// This code was generated by Refitter. | ||
// </auto-generated> | ||
|
||
using Refit; | ||
using System.Collections.Generic; | ||
using System.Text.Json.Serialization; | ||
using System.Threading.Tasks; | ||
|
||
using Refitter.Tests.AdditionalFiles.SingeInterface; | ||
|
||
namespace Refitter.Tests.CustomGenerated | ||
{ | ||
[System.CodeDom.Compiler.GeneratedCode("Refitter", "1.0.0.0")] | ||
public partial interface IApiInCustomGeneratedFolder | ||
{ | ||
/// <summary> | ||
/// Update an existing pet by Id | ||
/// </summary> | ||
[Headers("Accept: application/xml, application/json")] | ||
[Put("/pet")] | ||
Task<Pet> UpdatePet([Body] Pet body); | ||
|
||
/// <summary> | ||
/// Add a new pet to the store | ||
/// </summary> | ||
[Headers("Accept: application/xml, application/json")] | ||
[Post("/pet")] | ||
Task<Pet> AddPet([Body] Pet body); | ||
|
||
/// <summary> | ||
/// Multiple status values can be provided with comma separated strings | ||
/// </summary> | ||
[Headers("Accept: application/json")] | ||
[Get("/pet/findByStatus")] | ||
Task<ICollection<Pet>> FindPetsByStatus([Query] Status? status); | ||
|
||
/// <summary> | ||
/// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. | ||
/// </summary> | ||
[Headers("Accept: application/json")] | ||
[Get("/pet/findByTags")] | ||
Task<ICollection<Pet>> FindPetsByTags([Query(CollectionFormat.Multi)] IEnumerable<string> tags); | ||
|
||
/// <summary> | ||
/// Returns a single pet | ||
/// </summary> | ||
[Headers("Accept: application/xml, application/json")] | ||
[Get("/pet/{petId}")] | ||
Task<Pet> GetPetById(long petId); | ||
|
||
[Post("/pet/{petId}")] | ||
Task UpdatePetWithForm(long petId, [Query] string name, [Query] string status); | ||
|
||
[Delete("/pet/{petId}")] | ||
Task DeletePet(long petId, [Header("api_key")] string api_key); | ||
|
||
[Headers("Accept: application/json")] | ||
[Post("/pet/{petId}/uploadImage")] | ||
Task<ApiResponse> UploadFile(long petId, [Query] string additionalMetadata, StreamPart body); | ||
|
||
/// <summary> | ||
/// Returns a map of status codes to quantities | ||
/// </summary> | ||
[Headers("Accept: application/json")] | ||
[Get("/store/inventory")] | ||
Task<IDictionary<string, int>> GetInventory(); | ||
|
||
/// <summary> | ||
/// Place a new order in the store | ||
/// </summary> | ||
[Headers("Accept: application/json")] | ||
[Post("/store/order")] | ||
Task<Order> PlaceOrder([Body] Order body); | ||
|
||
/// <summary> | ||
/// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions | ||
/// </summary> | ||
[Headers("Accept: application/json")] | ||
[Get("/store/order/{orderId}")] | ||
Task<Order> GetOrderById(long orderId); | ||
|
||
/// <summary> | ||
/// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors | ||
/// </summary> | ||
[Delete("/store/order/{orderId}")] | ||
Task DeleteOrder(long orderId); | ||
|
||
/// <summary> | ||
/// This can only be done by the logged in user. | ||
/// </summary> | ||
[Headers("Accept: application/json, application/xml")] | ||
[Post("/user")] | ||
Task CreateUser([Body] User body); | ||
|
||
/// <summary> | ||
/// Creates list of users with given input array | ||
/// </summary> | ||
[Headers("Accept: application/xml, application/json")] | ||
[Post("/user/createWithList")] | ||
Task<User> CreateUsersWithListInput([Body] IEnumerable<User> body); | ||
|
||
[Headers("Accept: application/json")] | ||
[Get("/user/login")] | ||
Task<string> LoginUser([Query] string username, [Query] string password); | ||
|
||
[Get("/user/logout")] | ||
Task LogoutUser(); | ||
|
||
[Headers("Accept: application/json")] | ||
[Get("/user/{username}")] | ||
Task<User> GetUserByName(string username); | ||
|
||
/// <summary> | ||
/// This can only be done by the logged in user. | ||
/// </summary> | ||
[Put("/user/{username}")] | ||
Task UpdateUser(string username, [Body] User body); | ||
|
||
/// <summary> | ||
/// This can only be done by the logged in user. | ||
/// </summary> | ||
[Delete("/user/{username}")] | ||
Task DeleteUser(string username); | ||
|
||
|
||
} | ||
} | ||
|
||
|
||
|
22 changes: 22 additions & 0 deletions
22
src/Refitter.SourceGenerator.Tests/CustomOutputFolderGeneratorTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using FluentAssertions; | ||
|
||
using Refit; | ||
|
||
using Refitter.Tests.CustomGenerated; | ||
|
||
using Xunit; | ||
|
||
namespace Refitter.SourceGenerators.Tests; | ||
|
||
public class CustomOutputFolderGeneratorTests | ||
{ | ||
[Fact] | ||
public void Can_Create_File_In_Custom_Path() => | ||
File.Exists("../../../CustomGenerated/SwaggerPetstoreCustomOutputFolder.g.cs").Should().BeTrue(); | ||
|
||
[Fact] | ||
public void Can_Resolve_Refit_Interface() => | ||
RestService.For<IApiInCustomGeneratedFolder>("https://petstore3.swagger.io/api/v3") | ||
.Should() | ||
.NotBeNull(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters