Giter VIP home page Giter VIP logo

Comments (1)

ttu avatar ttu commented on May 18, 2024

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.

from dotnet-fake-json-server.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.