Skip to content

Commit

Permalink
default host (#40)
Browse files Browse the repository at this point in the history
* default host

* regen
  • Loading branch information
olydis authored Dec 1, 2017
1 parent e33085e commit 5fdd8b8
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/SwaggerModeler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,11 @@ private void InitializeClientModel()
? null // ...but that mocks with our multi-api-version treatment of inlining the api-version
: ServiceDefinition.Info.Version;
CodeModel.Documentation = ServiceDefinition.Info.Description;
CodeModel.BaseUrl = ServiceDefinition.Servers[0].Url.TrimEnd('/');
CodeModel.BaseUrl = ServiceDefinition.Servers.FirstOrDefault()?.Url?.TrimEnd('/');
if (string.IsNullOrEmpty(CodeModel.BaseUrl))
{
CodeModel.BaseUrl = "http://localhost";
}

// Copy extensions
ServiceDefinition.Info?.CodeGenerationSettings?.Extensions.ForEach(extention => CodeModel.CodeGenExtensions.AddOrSet(extention.Key, extention.Value));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
apiVersion: 1.0.0
baseUrl: ''
baseUrl: 'http://localhost'
documentation: Test Infrastructure for AutoRest Swagger BAT
modelsName: Models
name: AutoRestSwaggerBATFormDataService
Expand Down
2 changes: 1 addition & 1 deletion test/Expected/body-formdata-urlencoded/code-model-v1.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
apiVersion: 1.0.0
baseUrl: ''
baseUrl: 'http://localhost'
documentation: Test Infrastructure for AutoRest Swagger BAT
modelsName: Models
name: AutoRestSwaggerBATFormDataService
Expand Down
2 changes: 1 addition & 1 deletion test/Expected/specs-search/code-model-v1-yaml.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
apiVersion: '2016-09-01'
baseUrl: ''
baseUrl: 'http://localhost'
codeGenExtensions:
syncMethods: None
useDateTimeOffset: true
Expand Down
2 changes: 1 addition & 1 deletion test/Expected/specs-search/code-model-v1.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
apiVersion: '2016-09-01'
baseUrl: ''
baseUrl: 'http://localhost'
codeGenExtensions:
syncMethods: None
useDateTimeOffset: true
Expand Down

0 comments on commit 5fdd8b8

Please sign in to comment.