Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Controller Path/Tree Support #73

Open
Shanjaq opened this issue Mar 19, 2020 · 1 comment
Open

Controller Path/Tree Support #73

Shanjaq opened this issue Mar 19, 2020 · 1 comment

Comments

@Shanjaq
Copy link

Shanjaq commented Mar 19, 2020

using a web service tree with controller paths like:

garage/v3.0/storage/Bins
garage/v3.0/storage/Shelves
garage/v3.0/workbench/Tools

I haven't been able to figure out how to mock these, even manually editing datastore.json as follows and calling Reload:

{ "garage/v3.0/storage/Bins": [ { "Type": "Large", "id": 0 }, { "Type": "Small", "id": 1 } ] }

I see there is support for nested items, but this requires specifying an item ID at each level which will not match the paths used by the real service.

@Shanjaq Shanjaq changed the title Nested Controller Support Controller Path Support Mar 19, 2020
@Shanjaq Shanjaq changed the title Controller Path Support Controller Path/Tree Support Mar 19, 2020
@ttu
Copy link
Owner

ttu commented Mar 22, 2020

Thanks for the issue.

Unfortunately this kind of path/naming is not supported.

curl -X GET "http://localhost:57603/api/garage/v3.0/storage/bins" -H "accept: application/json"

Now API tries to look for items, with these parameters:

collection=garage
id=v3.0
path=storage/bins

Supporting slashes in collection names could be possible, but would require lots of changes as current implementation relies on dividing the request by slashes.

{
  "garage/v3.0/storage/bins": [
    {
      "type": "Large",
      "id": 0
    },
    {
      "type": "Small",
      "id": 1
    }
  ],
  "garage/v3.0/storage/shelves": [
    {
      "type": "Large",
      "id": 0
    },
    {
      "type": "Small",
      "id": 1
    }
  ],
}

As you mentioned you can get this almost working by using nested items.

Change ApiRoute from Config file:

public class Config
{
	public const string ApiRoute = "garage/v3.0";
	public const string AsyncRoute = "async";
	public const string GraphQLRoute = "graphql";
	public const string TokenRoute = "token";
	public const string TokenLogoutRoute = "logout";
}

Json file should be like this:

{
  "storage": [
    {
      "id": "bins",
      "bins": [
        {
          "type": "Large",
          "id": "0"
        },
        {
          "type": "Small",
          "id": "1"
        }
      ]
    },
    {
      "id": "shelves",
      "shelves": [
        {
          "type": "High",
          "id": "0"
        },
        {
          "type": "Low",
          "id": "1"
        }
      ]
    }
  ]
}

Query has unfortunately double bins as now bins is an id and the name of the collection property.

curl -X GET "http://localhost:57603/api/garage/v3.0/storage/bins/bins/0" -H "accept: application/json"

Correct implementation would be that single items would support searching for nested properties. Now only collections support that.

Then we could query inside an item. Now only whole item can be returned.

curl -X GET "http://localhost:57603/api/garage/v3.0/storage/" -H "accept: application/json"
{
  "storage": {
    "bins": [
      {
        "type": "Large",
        "id": 0
      },
      {
        "type": "Small",
        "id": 1
      }
    ],
    "shelves": [
      {
        "type": "High",
        "id": 0
      },
      {
        "type": "Low",
        "id": 1
      }
    ]
  },
  "workbench": {
    "tools": [
      {
        "type": "Hammer",
        "id": 0
      },
      {
        "type": "Saw",
        "id": 1
      }
    ]
  }
}

Have to think what would be the best way to implement this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants