• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

how to create an api that can adapt to dynamic fields

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all
I am new to APIs and am working on create an API that can extensible and flexible . . How would I abstract that information. Any suggestion or guidance ,would greatly be appreciate . I have been reading a few books and am confused
The use case is an object can have state specific attributes and state specific values .
I will use Tesla in this hypothetical  example
It can create {model3, p85,p100,plad,plad+}models , in the state of AZ , they only build available is "plad" model  . In  the NY they only build is "plad+" model. But in the state of NY they also add an hitch option

I have provide 3 options  below . Please let me know which one do you prefer or is there another option ?

For example if I make an API call
[option1]
www.yyy.com\cars\tesla



But the above does not seem right to me



[option 2]
should I do it like this
www.yyy.com\cars\tesla\AZ



and



www.yyy.com\cars\tesla\NY





or
[option 3]
www.yyy.com\cars\tesla




like the solution for the last option above ,To deign based on  the above solution
Not sure on the c#/java code on how to construct . If they had another state specific behavior similar to build

Would the approach of a class interface with  50 sub states work to have state specific attributes ? Does this approach cause issues  , or is this a good way to go.


Finally ,  but am not sure how do I create dynamic information for swagger or how do I create dynamic documentation  for client to consume that they will know the dynamic values
I was looking to create documentation on my API , and thought of using swagger . But swagger does not enable dynamic represent ion . How do I communicate this on my API any other suggestions on documentation .
[option 1] is easy to document , [option 3] is hard to document



Thanks for taking time to read and appreciate your help

-Ryder



 
Saloon Keeper
Posts: 7174
166
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If the client knows which state to query, then option 2 feels best; it's what a RESTful API would look like.

If you need to make the amount of data returned more dynamic -not all data attributes need to be returned at all times- then check out GraphQL. It's for building APIs that can query and return data according to the client's stated needs at a particular moment.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic