Skip to content

Commit

Permalink
Fix download json&yaml bug and remove google analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
lqtian authored and LianwMS committed Aug 16, 2016
1 parent c98b7b4 commit 885a308
Show file tree
Hide file tree
Showing 6 changed files with 166 additions and 76 deletions.
5 changes: 0 additions & 5 deletions config/defaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@
"server": "http://morpho-codegen.azurewebsites.net/server/codegen/?name={language}",
"client": "http://morpho-codegen.azurewebsites.net/client/codegen/?name={language}"
},
"analytics": {
"google": {
"id": "UA-51231036-1"
}
},
"disableCodeGen": false,
"examplesFolder": "spec-files/",
"editorOptions": {
Expand Down
6 changes: 0 additions & 6 deletions scripts/analytics/google.js

This file was deleted.

2 changes: 1 addition & 1 deletion scripts/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ require('scripts/plugins/jquery.scroll-into-view.js');

// Misc
require('scripts/ace/snippets/swagger.snippet.js');
require('scripts/analytics/google.js');
//require('scripts/analytics/google.js');

// Ace Editor
window.ace = require('brace');
Expand Down
5 changes: 4 additions & 1 deletion scripts/controllers/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,12 @@ SwaggerEditor.controller('HeaderCtrl', function HeaderCtrl($scope, $uibModal,

var assign = function(yaml, json) {
// swagger and version should be a string to comfort with the schema
if (json.info.version) {
if (json.info&&json.info.version) {
json.info.version = String(json.info.version);
}
if (json.api.version&&json.api.version.current) {
json.api.version.current = String(json.api.version.current);
}
if (json.swagger) {
if (json.swagger === 2) {
json.swagger = '2.0';
Expand Down
152 changes: 104 additions & 48 deletions spec-files/guide.yaml
Original file line number Diff line number Diff line change
@@ -1,49 +1,105 @@
# Example YAML to get you started quickly.
# Be aware that YAML has indentation based scoping.
# Code completion support is available so start typing for available options.
swagger: '2.0'
# This YAML file lays out the full definition of what a model-first YAML file can contain.

# This is your document metadata
info:
version: "0.0.0"
title: <enter your title>

# Describe your paths here
paths:
# This is a path endpoint. Change it.
/persons:
# This is a HTTP operation
get:
# Describe this verb here. Note: you can use markdown
description: |
Gets `Person` objects.
Optional query param of **size** determines
size of returned array
# This is array of GET operation parameters:
parameters:
# An example parameter that is in query and is required
-
name: size
in: query
description: Size of array
required: true
type: number
format: double
# Expected responses for this operation:
responses:
# Response code
200:
description: Successful response
# A schema describing your response object.
# Use JSON Schema format
schema:
title: ArrayOfPersons
type: array
items:
title: Person
type: object
properties:
name:
type: string
single:
type: boolean
# The api section defines metadata about the service - name, contact info, etc.
api: # Required
name: REST API Name # Required
version: # Optional
current: 1.0.0
description: This REST API does something amazing! # Optional
namespace: "REST.API.Namespace" # Optional, default generated from the name
host: services.example.org # Optional
basePath: /base/path # Optional. Or rootUrl to replace host and basePath
termsOfService: http://example.org/tos # Optional
contact: # Optional
name: API Support
url: http://www.example.io/support
email: support@example.io
license: # Optional
name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html
auth: Basic # Optional
conformance: minimal # Optional
supportsFilterFunctions: [contains, endswith, startswith, length, indexof, substring, tolower, toupper, trim, concat, year, month, day, hour, minute, second, round, floor, ceiling, cast, isof] # Optional

root: # Required.
# Collection
- name: EntitySet # Required.
type: EntityType[] # Required.
allows: [read, create, update, delete] # Optional
searchable: true # Optional
insertable: true # Optional
deletable: false # Optional
concurrencyProperties: concurrency # Optional. Data modification requires the use of ETags.
disallowNavigation: navigationProperty # Optional
disallowInsert: [navigationProperty] # Optional
# Singleton
- name: Singleton # Required.
type: EntityType # Required.
# Operation
- name: QueryFunction # Required.
params: # Optional
- name: userId # Required.
type: int32 # Optional. Default string.
returns: EntityType[] # Required.
- name: ExecuteAction
params: # Optional
- name: parameterName # Required.
type: int32 # Optional. Default string.

# The types section defines types used the service.
types: # Required.
# Enumeration type
- name: EnumType # Required.
members: # Required.
- name: none
value: 0 # Optional
- name: enum1
value: 1 # Optional
- name: enum2
value: 2 # Optional
# Complex type
- name: BaseType
requiredProperties: # Optional
- name: price # Required.
type: decimal # Optional
isoCurrency: USD # Optional. The currency for this monetary amount as an ISO 4217 currency code
immutable: true # Optional. A value for this non-key property can be provided on insert and remains unchanged on update
# Entity type
- name: EntityType # Required.
key: # Required.
- name: id # Optional
baseType: BaseType # Optional
dynamic: true # Optional. dynamic type allows clients to add properties dynamically to instances of the type by specifying uniquely named values in the payload used to insert or update an instance of the type.
requiredProperties: # Optional
- name: name # Required.
type: string # Optional
- name: enumProperty # Required.
type: EnumType # Optional
- name: location # Required.
type: geographypoint # Optional
optionalProperties: # Optional
- name: concurrency # Required.
type: int64 # Optional
computed: true # Optional。 A value for this property is generated on both insert and update
- name: navigationProperty # Required.
type: AnotherEntityType # Optional
containsTarget: true # Optional. Containment navigation properties define an implicit entity set for each instance of its declaring entity type. This implicit entity set is identified by the read URL of the navigation property for that entity.
operations: # Optional
- name: BoundOperation # Required.
params: # Optional
- name: parameterName # Required.
type: string # Optional
returns: EntityType # Optional
- name: AnotherEntityType # Required.
key: Id # Required.
hasStream: false # Optional. A value of true specifies that the entity type is a media entity.
requiredProperties: # Optional
- name: name # Required.
type: string # Optional
computed: false # Optional
operations: # Optional
- name: BoundToContainedType # Required.
params: # Optional
- name: parameterName # Required.
type: string # Optional
returns: AnotherEntityType # Optional
72 changes: 57 additions & 15 deletions spec-files/simpleTrippin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,64 @@ api:
version:
current: 1.0.0
description: "TripPin is a fictional reference service demonstrating the capabilities of OData v4."
namespace: "Microsoft.OData.SampleService.Models.TripPin"
host: services.odata.org
basePath: /V4/TripPinServiceRW
termsOfService: http://swagger.io/terms/
contact:
name: API Support
url: http://www.swagger.io/support
email: support@swagger.io
license:
name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html
auth: none
conformance: minimal
supportsFilterFunctions: [contains, endswith, startswith, length, indexof, substring, tolower, toupper, trim, concat, year, month, day, hour, minute, second, round, floor, ceiling, cast, isof]
host: services.odata.org
basePath: /V4/(S(cnbm44wtbc1v5bgrlek5lpcc))/TripPinServiceRW

root:
- name: Photos
- name: photos
type: photo[]
allows : [read, create, delete]
searchable: true
insertable: true
- name: People
- name: people
type: person[]
allows : [update]
searchable: true
insertable: true
concurrencyProperties: concurrency
disallowNavigation: friends
disallowInsert: [trips, friends]
- name: Airlines
- name: airlines
type: airline[]
allows : [read, update]
searchable: true
insertable: true
- name: Airports
- name: airports
type: airport[]
searchable: true
insertable: false
deletable: false
- name: Me
- name: me
type: person
- name: GetNearestAirport
- name: getNearestAirport
params:
- name: lat
type: double
- name: lon
type: double
returns: airport
- name: ResetDataSource
- name: resetDataSource

types:
types:
- name: personGender
members:
- name: unknown
value: 0
- name: female
value: -1
- name: male
value: 2
flags: false
underlyingType: int32
- name: city
requiredProperties: [countryRegion, name, region]
- name: location
Expand All @@ -54,6 +70,9 @@ types:
- address
- name: city
type: city
- name: eventLocation
baseType: location
optionalProperties: buildingInfo
- name: airportLocation
baseType: location
requiredProperties:
Expand All @@ -77,13 +96,16 @@ types:
type: string[]
- name: addressInfo
type: location[]
- name: gender
type: personGender
- name: concurrency
type: int64
computed: true
- name: friends
type: person[]
- name: trips
type: trip[]
containsTarget: true
- name: photo
type: photo
operations:
Expand All @@ -94,7 +116,7 @@ types:
returns: trip[]
- name: shareTrip
params:
- userName
- sharedTo
- name: tripId
type: int32
- name: airline
Expand Down Expand Up @@ -122,6 +144,26 @@ types:
type: dateTimeOffset
- name: duration
type: duration
- name: publicTransportation
baseType: planItem
optionalProperties: seatNumber
- name: flight
baseType: publicTransportation
requiredProperties: flightNumber
optionalProperties:
- name: from
type: airport
- name: to
type: airport
- name: airline
type: airline
- name: event
baseType: planItem
dynamic: true
optionalProperties:
- description
- name: occursAt
type: eventLocation
- name: trip
key: tripId
requiredProperties:
Expand All @@ -142,4 +184,4 @@ types:
contained: true
operations:
- name: getInvolvedPeople
returns: person[]
returns: person[]

0 comments on commit 885a308

Please sign in to comment.