{"action":"created","issue":{"url":"https://api.github.com/repos/Azure/autorest/issues/2896","repository_url":"https://api.github.com/repos/Azure/autorest","labels_url":"https://api.github.com/repos/Azure/autorest/issues/2896/labels{/name}","comments_url":"https://api.github.com/repos/Azure/autorest/issues/2896/comments","events_url":"https://api.github.com/repos/Azure/autorest/issues/2896/events","html_url":"https://github.com/Azure/autorest/issues/2896","id":312160036,"number":2896,"title":"Generate client library without using AutoRest command line?","user":{"login":"scott-lin","id":31644762,"avatar_url":"https://avatars2.githubusercontent.com/u/31644762?v=4","gravatar_id":"","url":"https://api.github.com/users/scott-lin","html_url":"https://github.com/scott-lin","followers_url":"https://api.github.com/users/scott-lin/followers","following_url":"https://api.github.com/users/scott-lin/following{/other_user}","gists_url":"https://api.github.com/users/scott-lin/gists{/gist_id}","starred_url":"https://api.github.com/users/scott-lin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scott-lin/subscriptions","organizations_url":"https://api.github.com/users/scott-lin/orgs","repos_url":"https://api.github.com/users/scott-lin/repos","events_url":"https://api.github.com/users/scott-lin/events{/privacy}","received_events_url":"https://api.github.com/users/scott-lin/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-04-07T01:33:02Z","updated_at":"2018-04-18T01:13:43Z","closed_at":null,"author_association":"NONE","body":"Hi,\r\n\r\nIs it possible to generate client libraries by using AutoRest as a library (call into APIs it exposes) as compared to installing and invoking via the command line? Are there samples on how to do this? Please excuse me if I missed them. I did not see this use case highlighted on https://github.com/Azure/autorest.\r\n\r\nMy ultimate goal is to \"AutoRest as a service\". That is, setup a lightweight RESTful service to handle requests for generating client libraries (by using AutoRest under the hood). I was hoping to setup a NodeJS server and invoke AutoRest APIs in my web service API. Ideally, I would develop the server using TypeScript and interface with AutoRest APIs in this context. Is this even feasible?\r\n\r\nI've been poking around to find TypeScript declarations for AutoRest in order to put together a basic proof of concept / prototype, but I cannot find any. For example, searching https://microsoft.github.io/TypeSearch for AutoRest produces no hits. I do notice an `autorest-code.d.ts`, however, when installing `@microsoft.azure/autorest-core`. \r\n\r\n![image](https://user-images.githubusercontent.com/31644762/38449684-05d75fba-39c7-11e8-9bad-1e3022322fc5.png)\r\n\r\nAny guidance or samples you can point me to is much appreciated. Sorry this isn't exactly an \"issue\", but more of a cry for help. 😄 Let me know if there a better place for my inquiry.\r\n\r\nThanks."},"comment":{"url":"https://api.github.com/repos/Azure/autorest/issues/comments/382211224","html_url":"https://github.com/Azure/autorest/issues/2896#issuecomment-382211224","issue_url":"https://api.github.com/repos/Azure/autorest/issues/2896","id":382211224,"user":{"login":"scott-lin","id":31644762,"avatar_url":"https://avatars2.githubusercontent.com/u/31644762?v=4","gravatar_id":"","url":"https://api.github.com/users/scott-lin","html_url":"https://github.com/scott-lin","followers_url":"https://api.github.com/users/scott-lin/followers","following_url":"https://api.github.com/users/scott-lin/following{/other_user}","gists_url":"https://api.github.com/users/scott-lin/gists{/gist_id}","starred_url":"https://api.github.com/users/scott-lin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scott-lin/subscriptions","organizations_url":"https://api.github.com/users/scott-lin/orgs","repos_url":"https://api.github.com/users/scott-lin/repos","events_url":"https://api.github.com/users/scott-lin/events{/privacy}","received_events_url":"https://api.github.com/users/scott-lin/received_events","type":"User","site_admin":false},"created_at":"2018-04-18T01:13:43Z","updated_at":"2018-04-18T01:13:43Z","author_association":"NONE","body":"Thanks for the feedback. Here is my code based on all the comments, which is producing an error of `[Exception] No input files provided`. I suspect I'm defining the file system interface incorrectly?\r\n\r\n```\r\nlet options = { namespace: 'Foo' };\r\nlet openApiDocument = { \"swagger\": 2.0, \"info\": { \"title\": \"This is a simple example\", \"version\": \"1.0.0\" }, \"host\": \"example.org\", \"basePath\": \"/api\", \"schemes\": [\"http\", \"https\"], \"paths\": {} };\r\n\r\ntry {\r\n    const autorest = await create(new SingleItemFileSystem(JSON.stringify(openApiDocument)));\r\n    autorest.AddConfiguration({ 'csharp': options });\r\n\r\n    const messages = [];\r\n    autorest.Message.Subscribe((_, x) => messages.push(x));\r\n    autorest.GeneratedFile.Subscribe((_, x) => { /* Do something with artifact x */ });\r\n\r\n    const result = await autorest.Process().finish;\r\n    if (result !== true) throw result;\r\n    console.log(messages);\r\n}\r\ncatch (error) {\r\n    console.log(`Failed to run AutoRest with error: ${error.message}`);\r\n}\r\n```\r\n\r\nMy [file system](https://github.com/Azure/autorest/blob/d7aec27608b0549ebf808b81046d82b0ff5b75eb/src/autorest-core/lib/file-system.ts#L12) implementation is as follows. I'm basically taking in the OpenAPI document content in the constructor and trying to return it from the `ReadFile` method. I don't have a need to enumerate file URIs, so I was hoping I could send back a dummy value in the array. Let me know if I'm using this interface incorrectly.\r\n\r\n```\r\nexport class SingleItemFileSystem implements IFileSystem {\r\n    public constructor(content: string) {\r\n        this.content = content;\r\n    }\r\n\r\n    private content: string;\r\n\r\n    async EnumerateFileUris(folderUri: string): Promise<Array<string>> {\r\n        return ['dummyUri'];\r\n    }\r\n    \r\n    async ReadFile(uri: string): Promise<string> {\r\n        return this.content;\r\n    }\r\n}\r\n```"}}
{"actor":{"display_login":"scott-lin"}}