-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
CLI: a command to create a new service #1312
Comments
Yes.
The only artifact we need for service proxy is the data source for a service-oriented connector. I don't see the immediate requirement to make service declarative beyond the data source itself. |
See the example in #1311. When writing tests of a service proxy, users should not need to bootstrap the full app in order to access the service proxy instance. Ideally, the tests should not need to know how the service proxy is created at all - the creation aspect should be captured in one place only. import {GeoService} from '../services/geo.service';
import {expect} from '@loopback/testlab';
describe('GeoService', () => {
let service: GeoService;
beforeEach(() => service = new GeoService());
describe('geocode', () => {
it('returns geo coords for a given address', () => {
const result = await service.geocode('107 S B St', 'San Mateo', '94401');
// { lat: 37.5669986, lng: -122.3237495 }
expect(result.lat).approximately(37.5669986, 0.5);
expect(result.lng).approximately(-122.3237495, 0.5);
});
});
}); |
cc @strongloop/sq-lb-apex @raymondfeng @hacksparrow @bajtos Any more comments before getting it ready for estimation? |
So my understanding is that the story is about creating a |
I have slightly updated the issue description to mention that Service booter is already implemented, and also marked the last two items are should-have/nice-to-have.
+1 to create json/ts datasource file (possibly by delegating to If it makes the implementation any easier, then I am fine with splitting the process of creating a new service into two steps (two CLI invocations):
I don't think there is a single template that would work for all REST/SOAP services. I think we should create an empty definition of remote methods and let the user to manually fill in the template afterwards. Isn't this the same we do in LoopBack 3.x? We can help the user by asking for few things that are common to all services, for example a path/URL of a WSDL file for a SOAP service, a base URL for a REST service, etc. Let's work incrementally and keep the initial CLI implementation simple. To me, the most important goal is to create a @marioestradarosa do you have any opinion on how a CLI command |
What is a service? A model-like interface to an external API / web service / resource? Service should be added to the list of "Key concepts". |
See https://loopback.io/doc/en/lb4/Calling-other-APIs-and-web-services.html
+1 could you please create a new story or perhaps open a pull request? |
|
One thing important in services are the remote methods and how we define them locally. I think that having the wsdl on hand, the service generator can inspect and create the methods stated in the wsdl. This can save a lot of time for the app developer. I believe that for REST based datasources it will be more complicated as there is nothing standard such as the wsdl file, of course there are openAPI endpoints we can use to discover remote methods, but not all REST endpoints uses it. Moreover, I think that users can be presented a list of remote methods previously inferred from remote or local wsdl so they can choose which ones they would like to include in the service interface. |
Yes, that's the final outcome.
That's excellent @raymondfeng to use the current specs to create/inspect remote openAPI endpoints. So, for me the most time consuming task is to fill out the remote method signatures and if we can create it for the user would be good. So, we should write the JSON datasource with methods and create the service interface also with these methods, the reamining code is almost similar.
If the above command installs the service proxy, inspects the wsdl, generates the json file with remote methods and the my-service-name.service.ts with the service interface, that could really help a lot. However, we can create this PR with the basic first and then a second one with integration for SOAP and REST inferring their methods. |
Let's start with the simplest form - a service with OpenAPI spec. LB3 has the |
you mean something like this? 'lb4 service myServiceName --openapi http://url/openapi.json --datasourceName testRemoteDS'
|
I am proposing to start with an increment smaller than that. IMO, this is the minimal useful increment that we should start with: Create a It will allow us to keep the pull request reasonably small. Adding a new generator involves quite a lot of ceremony/boilerplate code which is easier to review when there are no other features (like OpenAPI discovery) included. Once we have this dummy |
I agree with @bajtos for the incremental stages:
|
@raymondfeng on SOAP section, I have no questions so far. However, do you have an idea what we should do in some cases where the REST end point doesn't have a spec file and the only thing we have is its URL ? |
@marioestradarosa , the PR #1736 has merged. Is this ticket good to close? |
@dhmlau I believe so. The enhancement of the
|
@marioestradarosa , thanks. Do you have the follow-up tasks created? I may not have the details to open them :) |
Per @marioestradarosa , closing this as resolved. |
As per @raymondfeng comment above, this is the only thing we have, probably you could help with the soap first as this is the one I want to focus for now? . As @bajtos mentioned also the work on both SOAP and REST can be done in parallel. |
This is a follow-up for #1267
There should be a new CLI command for creating services, this command should:
The text was updated successfully, but these errors were encountered: