For developers working on Angular2 Web API projects, Swagger is a familiar name.
Swagger is a nice tool to expose and provide a documentation and a UI for testing Web API controllers and methods (Generally speaking for RESTful APIs).
“Resource objects” appear in a JSON API document to represent resources.
A resource object MUST contain at least the following top-level members: member is not required when the resource object originates at the client and represents a new resource to be created on the server.
Defining a provider for API_Base URL, would be as easy is adding the highlighted code to the app module, Hard-coding a configuration though is not what we want in a real world project.
The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in RFC 2119 [RFC2119].
Clients MUST send all JSON API data in request documents with the header .
I’ve seen many Java Script developers who don’t care about hard-coding such things and tend to fix these problems through task runners (such as Gulp and Grunt). , whether you’re coding in Java or C# that compiles the code into binary files, or in Java Script/Typescript that goes plain text.
Once we want to take the Base Url out of the code, we face a serious problem. , we need to make an asynchronous call to the JSON file through HTTP, load the JSON file’s content and then get the API_BASE_URL‘s provider to return the value read from the JSON.