Commit a8faa056 authored by Martti Käärik's avatar Martti Käärik
Browse files

Corrected HTTP templates.

parent 597ecd5f
Loading
Loading
Loading
Loading
+168 −125
Original line number Diff line number Diff line
@Version: "1.0.0"
Package HTTP {
	
	Package MessageBasedConfiguration {
@@ -21,7 +22,7 @@ Package HTTP {
	Package MessageBased {
		Import all from TDL
		
        //Generic Method type
		// HTTP methods
		Enumerated Method {
			Method GET,
			Method POST,
@@ -36,6 +37,8 @@ Package HTTP {
			optional Method method,
			optional Headers headers,
			optional Parameters parameters,
			optional QueryParameters queryParameters,
			optional PathParameters pathParameters,
			optional Body body
		)
		
@@ -47,7 +50,7 @@ Package HTTP {
			optional Body body
		)
		
        //supporting types
		// Supporting types
		Collection Parameters of Parameter
		Structure Parameter (
			Location location,
@@ -57,21 +60,22 @@ Package HTTP {
		Enumerated Location {
			Location path,
			Location query,
            //may need a structure, not necessarily relevant in standardized testing
			// TODO may need a structure, not necessarily relevant in standardized testing
			Location cookie
		}
        //separate headers -> not necessary
        //Location header;
		
		Structure PathParameters ()
		Structure QueryParameters ()
		
		Collection Headers of Header
		Structure Header (
			String ^name,
			String ^value
            // not relevant in TDL? 
            // optional contentLength of type Integer,
            // optional contentType of type String 
		)
		
		// Base body for extension
		Structure Body ()
		
		// Basic string body
		Structure StringBody extends Body (
			String text
@@ -81,13 +85,14 @@ Package HTTP {
		Structure CollectionBody extends Body (
			Bodies items
		)
		
		// Any body can be included
		// If consistent type is needed, a custom subtype shall be defined and used 
		Collection Bodies of Body
    
		// Custom collection data instances can be defined
		// - inline in the responses 
		// - predefined as a separate data element
		
		// Custom collection data instances can be defined 
		// to enforce type consistency specific for API 
		
@@ -99,31 +104,69 @@ Package HTTP {
	} 
    
    Package Templates {
	    //Generic Request instances
		Import all from MessageBased
	    Request rGET ( )
	    Request rPOST ( )
	    Request rPUT ( )
	    Request rPATCH ( )
	    Request rDELETE ( )
		
		// Generic Request instances
		Request rGET (
			method = GET
		)
		Request rPOST (
			method = POST
		)
		Request rPUT (
			method = PUT
		)
		Request rPATCH (
			method = PATCH
		)
		Request rDELETE (
			method = DELETE
		)
		
		// Generic Response instances, name = status code        
	    Response r200 (statusMessage = "OK")
	    Response r201 (statusMessage = "Created")
	    Response r204 (statusMessage = "No Content")
	    Response r400 (statusMessage = "Bad Request")
	    Response r401 (statusMessage = "Not Found")
	    Response r403 (statusMessage = "Not Authorized")
	    Response r404 (statusMessage = "Forbidden")
		Response r200 (
			statusMessage = "OK"
		)
		Response r201 (
			statusMessage = "Created"
		)
		Response r204 (
			statusMessage = "No Content"
		)
		Response r400 (
			statusMessage = "Bad Request"
		)
		Response r401 (
			statusMessage = "Unauthorized"
		)
		Response r403 (
			statusMessage = "Forbidden"
		)
		Response r404 (
			statusMessage = "Not Found"
		)
		
		// Generic Response instances, name = status message        
	    Response OK (status = "200")
	    Response Created (status = "201")
	    Response NoContent (status = "204")
	    Response BadRequest (status = "400")
	    Response NotFound (status = "404")
	    Response NotAuthorized (status = "401")
	    Response Forbidden (status = "403")
    
		Response OK (
			status = 200
		)
		Response Created (
			status = 201
		)
		Response NoContent (
			status = 204
		)
		Response BadRequest (
			status = 400
		)
		Response NotFound (
			status = 404
		)
		Response NotAuthorized (
			status = 401
		)
		Response Forbidden (
			status = 403
		)
	}
}
 No newline at end of file
+159 −114
Original line number Diff line number Diff line
@Version: "1.0.0"
Package HTTP {
	Import all from TDL
	
	Package MessageBasedConfiguration {
		Import all from MessageBased
		Message Gate HTTPGate accepts Request,Response
		Message Gate HTTPSGate accepts Request,Response
		Component API {
			// Add variables and timers here or define new component types and configurations 
			gate HTTPGate http
			gate HTTPSGate https
		}
		Configuration BasicClientServer {
			API client as Tester,
			API poller as Tester,
			API server as SUT,
			connect client::http to server::http
		}
    
	}
	
	Note : "Message based types and instances"
	Package MessageBased {
		Import all from TDL
		
        //Generic Method type -> required for generation!!!
		// HTTP methods
		Enumerated Method {
			Method GET,
			Method POST,
@@ -36,16 +37,11 @@ Package HTTP {
			optional Method method,
			optional Headers headers,
			optional Parameters parameters,
			optional QueryParameters queryParameters,
			optional PathParameters pathParameters,
			optional Body body
		)
		
        //Generic Request instances
        Request GET ( )
        Request POST ( )
        Request PUT ( )
        Request PATCH ( )
        Request DELETE ( )
        
		// Generic Response type    
		Structure Response (
			optional Integer status,
@@ -54,26 +50,7 @@ Package HTTP {
			optional Body body
		)
		
        //Generic Response instances, name = status code
        
        Response r200 (statusMessage = "OK")
        Response r201 (statusMessage = "Created")
        Response r204 (statusMessage = "No Content")
        Response r400 (statusMessage = "Bad Request")
        Response r401 (statusMessage = "Not Found")
        Response r403 (statusMessage = "Not Authorized")
        Response r404 (statusMessage = "Forbidden")

        //Generic Response instances, name = status message        
        Response OK (status = "200")
        Response Created (status = "201")
        Response NoContent (status = "204")
        Response BadRequest (status = "400")
        Response NotFound (status = "404")
        Response NotAuthorized (status = "401")
        Response Forbidden (status = "403")
        
        //supporting types
		// Supporting types
		Collection Parameters of Parameter
		Structure Parameter (
			Location location,
@@ -83,11 +60,12 @@ Package HTTP {
		Enumerated Location {
			Location path,
			Location query,
			//may need a structure, not necessarily relevant in standardized testing
			// TODO may need a structure, not necessarily relevant in standardized testing
			Location cookie
		}
		
		Annotation QueryParameters
		Structure PathParameters ()
		Structure QueryParameters ()
		
		Collection Headers of Header
		Structure Header (
@@ -111,10 +89,10 @@ Package HTTP {
		// Any body can be included
		// If consistent type is needed, a custom subtype shall be defined and used 
		Collection Bodies of Body
        
		// Custom collection data instances can be defined
		// - inline in the responses 
		// - predefined as a separate data element
		
		// Custom collection data instances can be defined 
		// to enforce type consistency specific for API 
		
@@ -124,4 +102,71 @@ Package HTTP {
			String content
		)
	} 
    
    Package Templates {
		Import all from MessageBased
		
		// Generic Request instances
		Request rGET (
			method = GET
		)
		Request rPOST (
			method = POST
		)
		Request rPUT (
			method = PUT
		)
		Request rPATCH (
			method = PATCH
		)
		Request rDELETE (
			method = DELETE
		)
		
		// Generic Response instances, name = status code        
		Response r200 (
			statusMessage = "OK"
		)
		Response r201 (
			statusMessage = "Created"
		)
		Response r204 (
			statusMessage = "No Content"
		)
		Response r400 (
			statusMessage = "Bad Request"
		)
		Response r401 (
			statusMessage = "Unauthorized"
		)
		Response r403 (
			statusMessage = "Forbidden"
		)
		Response r404 (
			statusMessage = "Not Found"
		)
		
		// Generic Response instances, name = status message        
		Response OK (
			status = 200
		)
		Response Created (
			status = 201
		)
		Response NoContent (
			status = 204
		)
		Response BadRequest (
			status = 400
		)
		Response NotFound (
			status = 404
		)
		Response NotAuthorized (
			status = 401
		)
		Response Forbidden (
			status = 403
		)
	}
}
 No newline at end of file