question

Max Guernsey, III avatar image
Max Guernsey, III asked

Mocking the PlayFab APIs?

For automated integration tests, it would be nice to be able to run a dummy PlayFab service so that I could inject a URL rather than encapsulate every single API I'm using, mock it, and inject the mock.

Do you have anything like that? Is there a resource at which I could point a service generator in order to (easily) make one, myself?

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Max Guernsey, III avatar image
Max Guernsey, III answered

After looking around a bit, I realized, we can probably find what we need in the API generator.

https://github.com/PlayFab/SDKGenerator

In the frontmatter for that repo, you will find instructions on how to get the API spec. For instance, here:

https://github.com/PlayFab/API_Specs

***EDIT***

As I suspected, there is already a tool to generate server stubs:

https://github.com/swagger-api/swagger-codegen

***EDIT 2***

I'm a little embarrassed by what I had to do in order to make this work so I probably won't be open-source-ing the code any time, soon.

If other people express an interest, I can probably put a library up on NuGet. If someone at PlayFab wants to take over the code and make it part of the PlayFab offerings on NuGet, I will share with them and them alone my secret shame.

3 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Max Guernsey, III avatar image Max Guernsey, III commented ·

@Citrus Yan I'll build a pipeline to generate a mocking library, myself, when I get around to it. When I'm done, I'll submit an "idea" that y'all take over the repo and publish the result with the rest of your NuGet packages.

0 Likes 0 ·
Citrus Yan avatar image Citrus Yan Max Guernsey, III commented ·

That's sounds great!

0 Likes 0 ·
Max Guernsey, III avatar image Max Guernsey, III Citrus Yan commented ·

It's a little more work than I thought because they don't generate stubs specifically for mocking. However, it's pretty extensible, so adding that functionality should be pretty straightforward.

I know...famous last words.

1 Like 1 ·
Citrus Yan avatar image
Citrus Yan answered

Sorry, we don’t have a tool & resource for this, you may need to implement it by yourself.

3 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Max Guernsey, III avatar image Max Guernsey, III commented ·

I'm not too surprised that you don't have the tool.

I'm shocked that you don't have the resource, since your documentation says your SDKs are autogenerated using a tool. That tool must consume some kind of document/data.

Is it that you have it but simply do not wish to release it to the public?

0 Likes 0 ·
Citrus Yan avatar image Citrus Yan Max Guernsey, III commented ·

Not sure which data/document you're looking for exactly. Actually, all our SDKs are auto generated using the SDKGenerator, which is open to the public, hope you find it helpful.

0 Likes 0 ·
Max Guernsey, III avatar image Max Guernsey, III Citrus Yan commented ·

See my answer.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.