Add post processing to files generated by Haskell generators (#968)

* add hfmt support (without updating the sample)

* update haskell httpclient samples with hfmt

* add code format option to haskell servant, minor bug fixes

* update code samples with hfmt

* update samples using stylish-haskell

* rename env variable

* update haskell samples with stylish-haskell

* regenerate haskell samples without stylish-haskell

* regenerate haskell servant sample

* update example-app & tests-integration for OAS2 code
This commit is contained in:
William Cheng 2018-09-29 17:21:03 +08:00 committed by GitHub
parent f1f7bdd23f
commit cbddb08468
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 866 additions and 1243 deletions

View File

@ -30,7 +30,7 @@ sleep 5
./bin/typescript-node-petstore-all.sh > /dev/null 2>&1 ./bin/typescript-node-petstore-all.sh > /dev/null 2>&1
./bin/typescript-inversify-petstore.sh > /dev/null 2>&1 ./bin/typescript-inversify-petstore.sh > /dev/null 2>&1
./bin/rust-server-petstore.sh > /dev/null 2>&1 ./bin/rust-server-petstore.sh > /dev/null 2>&1
./bin/openapi3/haskell-http-client-petstore.sh > /dev/null 2>&1 ./bin/haskell-http-client-petstore.sh > /dev/null 2>&1
./bin/csharp-petstore.sh > /dev/null 2>&1 ./bin/csharp-petstore.sh > /dev/null 2>&1
./bin/meta-codegen.sh > /dev/null 2>&1 ./bin/meta-codegen.sh > /dev/null 2>&1
./bin/utils/export_docs_generators.sh > /dev/null 2>&1 ./bin/utils/export_docs_generators.sh > /dev/null 2>&1

View File

@ -24,6 +24,7 @@ import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.security.SecurityScheme; import io.swagger.v3.oas.models.security.SecurityScheme;
import org.apache.commons.lang3.StringEscapeUtils; import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
import org.openapitools.codegen.*; import org.openapitools.codegen.*;
import org.openapitools.codegen.utils.ModelUtils; import org.openapitools.codegen.utils.ModelUtils;
@ -361,6 +362,10 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
public void processOpts() { public void processOpts() {
super.processOpts(); super.processOpts();
if (StringUtils.isEmpty(System.getenv("HASKELL_POST_PROCESS_FILE"))) {
LOGGER.info("Hint: Environment variable HASKELL_POST_PROCESS_FILE not defined so the Haskell code may not be properly formatted. To define it, try 'export HASKELL_POST_PROCESS_FILE=\"$HOME/.local/bin/hfmt -w\"' (Linux/Mac)");
}
if (additionalProperties.containsKey(PROP_ALLOW_FROMJSON_NULLS)) { if (additionalProperties.containsKey(PROP_ALLOW_FROMJSON_NULLS)) {
setAllowFromJsonNulls(convertPropertyToBoolean(PROP_ALLOW_FROMJSON_NULLS)); setAllowFromJsonNulls(convertPropertyToBoolean(PROP_ALLOW_FROMJSON_NULLS));
} else { } else {
@ -1345,4 +1350,31 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
.replace("\\", "\\\\") .replace("\\", "\\\\")
.replace("\"", "\\\"")); .replace("\"", "\\\""));
} }
@Override
public void postProcessFile(File file, String fileType) {
if (file == null) {
return;
}
String haskellPostProcessFile = System.getenv("HASKELL_POST_PROCESS_FILE");
if (StringUtils.isEmpty(haskellPostProcessFile)) {
return; // skip if HASKELL_POST_PROCESS_FILE env variable is not defined
}
// only process files with hs extension
if ("hs".equals(FilenameUtils.getExtension(file.toString()))) {
String command = haskellPostProcessFile + " " + file.toString();
try {
Process p = Runtime.getRuntime().exec(command);
int exitValue = p.waitFor();
if (exitValue != 0) {
LOGGER.error("Error running the command ({}). Exit value: {}", command, exitValue);
} else {
LOGGER.info("Successfully executed: " + command);
}
} catch (Exception e) {
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
}
}
}
} }

View File

@ -21,6 +21,7 @@ import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation; import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.media.ArraySchema; import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.media.Schema;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.CliOption; import org.openapitools.codegen.CliOption;
import org.openapitools.codegen.CodegenConfig; import org.openapitools.codegen.CodegenConfig;
@ -36,6 +37,7 @@ import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
@ -179,6 +181,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
typeMapping.put("double", "Double"); typeMapping.put("double", "Double");
typeMapping.put("DateTime", "Integer"); typeMapping.put("DateTime", "Integer");
typeMapping.put("file", "FilePath"); typeMapping.put("file", "FilePath");
typeMapping.put("binary", "FilePath");
typeMapping.put("number", "Double"); typeMapping.put("number", "Double");
typeMapping.put("any", "Value"); typeMapping.put("any", "Value");
typeMapping.put("UUID", "Text"); typeMapping.put("UUID", "Text");
@ -192,6 +195,15 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
cliOptions.add(new CliOption(CodegenConstants.API_PACKAGE, CodegenConstants.API_PACKAGE_DESC)); cliOptions.add(new CliOption(CodegenConstants.API_PACKAGE, CodegenConstants.API_PACKAGE_DESC));
} }
@Override
public void processOpts() {
super.processOpts();
if (StringUtils.isEmpty(System.getenv("HASKELL_POST_PROCESS_FILE"))) {
LOGGER.info("Hint: Environment variable HASKELL_POST_PROCESS_FILE not defined so the Haskell code may not be properly formatted. To define it, try 'export HASKELL_POST_PROCESS_FILE=\"$HOME/.local/bin/hfmt -w\"' (Linux/Mac)");
}
}
/** /**
* Escapes a reserved word as defined in the `reservedWords` array. Handle escaping * Escapes a reserved word as defined in the `reservedWords` array. Handle escaping
* those terms here. This logic is only called if a variable matches the reserved words * those terms here. This logic is only called if a variable matches the reserved words
@ -200,7 +212,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
*/ */
@Override @Override
public String escapeReservedWord(String name) { public String escapeReservedWord(String name) {
if(this.reservedWordsMappings().containsKey(name)) { if (this.reservedWordsMappings().containsKey(name)) {
return this.reservedWordsMappings().get(name); return this.reservedWordsMappings().get(name);
} }
return "_" + name; return "_" + name;
@ -232,7 +244,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
String title = openAPI.getInfo().getTitle(); String title = openAPI.getInfo().getTitle();
// Drop any API suffix // Drop any API suffix
if(title == null) { if (title == null) {
title = "OpenAPI"; title = "OpenAPI";
} else { } else {
title = title.trim(); title = title.trim();
@ -272,7 +284,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
List<Map<String, Object>> replacements = new ArrayList<>(); List<Map<String, Object>> replacements = new ArrayList<>();
Object[] replacementChars = specialCharReplacements.keySet().toArray(); Object[] replacementChars = specialCharReplacements.keySet().toArray();
for(int i = 0; i < replacementChars.length; i++) { for (int i = 0; i < replacementChars.length; i++) {
String c = (String) replacementChars[i]; String c = (String) replacementChars[i];
Map<String, Object> o = new HashMap<>(); Map<String, Object> o = new HashMap<>();
o.put("char", c); o.put("char", c);
@ -321,7 +333,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
return type; return type;
//if (languageSpecificPrimitives.contains(type)) //if (languageSpecificPrimitives.contains(type))
// return toModelName(type); // return toModelName(type);
} else if(typeMapping.containsValue(schemaType)) { } else if (typeMapping.containsValue(schemaType)) {
// TODO what's this case for? // TODO what's this case for?
type = schemaType + "_"; type = schemaType + "_";
} else { } else {
@ -452,7 +464,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
path.add("ReqBody '[JSON] " + param.dataType); path.add("ReqBody '[JSON] " + param.dataType);
bodyType = param.dataType; bodyType = param.dataType;
} }
} else if(op.getHasFormParams()) { } else if (op.getHasFormParams()) {
// Use the FormX data type, where X is the conglomerate of all things being passed // Use the FormX data type, where X is the conglomerate of all things being passed
String formName = "Form" + org.openapitools.codegen.utils.StringUtils.camelize(op.operationId); String formName = "Form" + org.openapitools.codegen.utils.StringUtils.camelize(op.operationId);
bodyType = formName; bodyType = formName;
@ -496,7 +508,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
op.vendorExtensions.put("x-routeType", joinStrings(" :> ", path)); op.vendorExtensions.put("x-routeType", joinStrings(" :> ", path));
op.vendorExtensions.put("x-clientType", joinStrings(" -> ", type)); op.vendorExtensions.put("x-clientType", joinStrings(" -> ", type));
op.vendorExtensions.put("x-formName", "Form" + org.openapitools.codegen.utils.StringUtils.camelize(op.operationId)); op.vendorExtensions.put("x-formName", "Form" + org.openapitools.codegen.utils.StringUtils.camelize(op.operationId));
for(CodegenParameter param : op.formParams) { for (CodegenParameter param : op.formParams) {
param.vendorExtensions.put("x-formPrefix", org.openapitools.codegen.utils.StringUtils.camelize(op.operationId, true)); param.vendorExtensions.put("x-formPrefix", org.openapitools.codegen.utils.StringUtils.camelize(op.operationId, true));
} }
return op; return op;
@ -504,12 +516,17 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
private String makeQueryListType(String type, String collectionFormat) { private String makeQueryListType(String type, String collectionFormat) {
type = type.substring(1, type.length() - 1); type = type.substring(1, type.length() - 1);
switch(collectionFormat) { switch (collectionFormat) {
case "csv": return "(QueryList 'CommaSeparated (" + type + "))"; case "csv":
case "tsv": return "(QueryList 'TabSeparated (" + type + "))"; return "(QueryList 'CommaSeparated (" + type + "))";
case "ssv": return "(QueryList 'SpaceSeparated (" + type + "))"; case "tsv":
case "pipes": return "(QueryList 'PipeSeparated (" + type + "))"; return "(QueryList 'TabSeparated (" + type + "))";
case "multi": return "(QueryList 'MultiParamArray (" + type + "))"; case "ssv":
return "(QueryList 'SpaceSeparated (" + type + "))";
case "pipes":
return "(QueryList 'PipeSeparated (" + type + "))";
case "multi":
return "(QueryList 'MultiParamArray (" + type + "))";
default: default:
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@ -550,19 +567,19 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
// Clean up the class name to remove invalid characters // Clean up the class name to remove invalid characters
model.classname = fixModelChars(model.classname); model.classname = fixModelChars(model.classname);
if(typeMapping.containsValue(model.classname)) { if (typeMapping.containsValue(model.classname)) {
model.classname += "_"; model.classname += "_";
} }
// From the model name, compute the prefix for the fields. // From the model name, compute the prefix for the fields.
String prefix = org.openapitools.codegen.utils.StringUtils.camelize(model.classname, true); String prefix = org.openapitools.codegen.utils.StringUtils.camelize(model.classname, true);
for(CodegenProperty prop : model.vars) { for (CodegenProperty prop : model.vars) {
prop.name = toVarName(prefix + org.openapitools.codegen.utils.StringUtils.camelize(fixOperatorChars(prop.name))); prop.name = toVarName(prefix + org.openapitools.codegen.utils.StringUtils.camelize(fixOperatorChars(prop.name)));
} }
// Create newtypes for things with non-object types // Create newtypes for things with non-object types
String dataOrNewtype = "data"; String dataOrNewtype = "data";
if(model.dataType != "object" && typeMapping.containsKey(model.dataType)) { if (!"object".equals(model.dataType) && typeMapping.containsKey(model.dataType)) {
String newtype = typeMapping.get(model.dataType); String newtype = typeMapping.get(model.dataType);
model.vendorExtensions.put("x-customNewtype", newtype); model.vendorExtensions.put("x-customNewtype", newtype);
} }
@ -585,4 +602,30 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
return input.replace("{-", "{_-").replace("-}", "-_}"); return input.replace("{-", "{_-").replace("-}", "-_}");
} }
@Override
public void postProcessFile(File file, String fileType) {
if (file == null) {
return;
}
String haskellPostProcessFile = System.getenv("HASKELL_POST_PROCESS_FILE");
if (StringUtils.isEmpty(haskellPostProcessFile)) {
return; // skip if HASKELL_POST_PROCESS_FILE env variable is not defined
}
// only process files with hs extension
if ("hs".equals(FilenameUtils.getExtension(file.toString()))) {
String command = haskellPostProcessFile + " " + file.toString();
try {
Process p = Runtime.getRuntime().exec(command);
int exitValue = p.waitFor();
if (exitValue != 0) {
LOGGER.error("Error running the command ({}). Exit value: {}", command, exitValue);
} else {
LOGGER.info("Successfully executed: " + command);
}
} catch (Exception e) {
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
}
}
}
} }

View File

@ -2,7 +2,7 @@
The library in `lib` provides auto-generated-from-OpenAPI [http-client](https://www.stackage.org/lts-10.0/package/http-client-0.5.7.1) bindings to the OpenAPI Petstore API. The library in `lib` provides auto-generated-from-OpenAPI [http-client](https://www.stackage.org/lts-10.0/package/http-client-0.5.7.1) bindings to the OpenAPI Petstore API.
OpenApi Version: 3.0.0 OpenApi Version: 3.0.1
## Installation ## Installation

View File

@ -155,6 +155,7 @@ runPet mgr config = do
-- * STORE -- * STORE
instance S.Consumes S.PlaceOrder S.MimeJSON
runStore :: NH.Manager -> S.OpenAPIPetstoreConfig -> IO () runStore :: NH.Manager -> S.OpenAPIPetstoreConfig -> IO ()
runStore mgr config = do runStore mgr config = do
@ -167,7 +168,7 @@ runStore mgr config = do
-- placeOrder -- placeOrder
now <- TI.getCurrentTime now <- TI.getCurrentTime
let placeOrderRequest = S.placeOrder (S.Accept S.MimeJSON) (S.mkOrder { S.orderId = Just 21, S.orderQuantity = Just 210, S.orderShipDate = Just (S.DateTime now)}) let placeOrderRequest = S.placeOrder (S.ContentType S.MimeJSON) (S.Accept S.MimeJSON) (S.mkOrder { S.orderId = Just 21, S.orderQuantity = Just 210, S.orderShipDate = Just (S.DateTime now)})
placeOrderResult <- S.dispatchMime mgr config placeOrderRequest placeOrderResult <- S.dispatchMime mgr config placeOrderRequest
mapM_ (\r -> putStrLn $ "placeOrderResult: " <> show r) placeOrderResult mapM_ (\r -> putStrLn $ "placeOrderResult: " <> show r) placeOrderResult
@ -188,22 +189,27 @@ runStore mgr config = do
-- * USER -- * USER
instance S.Consumes S.CreateUser S.MimeJSON
instance S.Consumes S.CreateUsersWithArrayInput S.MimeJSON
instance S.Consumes S.CreateUsersWithListInput S.MimeJSON
instance S.Consumes S.UpdateUser S.MimeJSON
runUser :: NH.Manager -> S.OpenAPIPetstoreConfig -> IO () runUser :: NH.Manager -> S.OpenAPIPetstoreConfig -> IO ()
runUser mgr config = do runUser mgr config = do
let username = "hsusername" let username = "hsusername"
-- createUser -- createUser
let user = S.mkUser { S.userId = Just 21, S.userUsername = Just username } let user = S.mkUser { S.userId = Just 21, S.userUsername = Just username }
let createUserRequest = S.createUser user let createUserRequest = S.createUser (S.ContentType S.MimeJSON) user
_ <- S.dispatchLbs mgr config createUserRequest _ <- S.dispatchLbs mgr config createUserRequest
-- can use lenses (model record names are appended L) to view or modify records -- can use lenses (model record names are appended L) to view or modify records
let users = take 8 $ drop 1 $ iterate (L.over S.userUsernameL (fmap (<> "*")) . L.over S.userIdL (fmap (+ 1))) user let users = take 8 $ drop 1 $ iterate (L.over S.userUsernameL (fmap (<> "*")) . L.over S.userIdL (fmap (+ 1))) user
let createUsersWithArrayInputRequest = S.createUsersWithArrayInput (S.User2 users) let createUsersWithArrayInputRequest = S.createUsersWithArrayInput (S.ContentType S.MimeJSON) (S.User2 users)
_ <- S.dispatchLbs mgr config createUsersWithArrayInputRequest _ <- S.dispatchLbs mgr config createUsersWithArrayInputRequest
-- createUsersWithArrayInput -- createUsersWithArrayInput
let createUsersWithListInputRequest = S.createUsersWithListInput (S.User2 users) let createUsersWithListInputRequest = S.createUsersWithListInput (S.ContentType S.MimeJSON) (S.User2 users)
_ <- S.dispatchLbs mgr config createUsersWithListInputRequest _ <- S.dispatchLbs mgr config createUsersWithListInputRequest
-- getUserByName -- getUserByName
@ -217,7 +223,7 @@ runUser mgr config = do
BCL.putStrLn $ "loginUser: " <> (NH.responseBody loginUserResult) BCL.putStrLn $ "loginUser: " <> (NH.responseBody loginUserResult)
-- updateUser -- updateUser
let updateUserRequest = S.updateUser (user { S.userEmail = Just "xyz@example.com" }) (S.Username username) let updateUserRequest = S.updateUser (S.ContentType S.MimeJSON) (user { S.userEmail = Just "xyz@example.com" }) (S.Username username)
_ <- S.dispatchLbs mgr config updateUserRequest _ <- S.dispatchLbs mgr config updateUserRequest
-- logoutUser -- logoutUser

View File

@ -1,4 +1,4 @@
resolver: lts-10.0 resolver: lts-10.10
packages: packages:
- location: '.' - location: '.'
- location: '..' - location: '..'

View File

@ -3,7 +3,7 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI Version: 3.0.0 OpenAPI Version: 3.0.1
OpenAPI Petstore API version: 1.0.0 OpenAPI Petstore API version: 1.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech) Generated by OpenAPI Generator (https://openapi-generator.tech)
-} -}

View File

@ -3,7 +3,7 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI Version: 3.0.0 OpenAPI Version: 3.0.1
OpenAPI Petstore API version: 1.0.0 OpenAPI Petstore API version: 1.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech) Generated by OpenAPI Generator (https://openapi-generator.tech)
-} -}

View File

@ -3,7 +3,7 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI Version: 3.0.0 OpenAPI Version: 3.0.1
OpenAPI Petstore API version: 1.0.0 OpenAPI Petstore API version: 1.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech) Generated by OpenAPI Generator (https://openapi-generator.tech)
-} -}

View File

@ -3,7 +3,7 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI Version: 3.0.0 OpenAPI Version: 3.0.1
OpenAPI Petstore API version: 1.0.0 OpenAPI Petstore API version: 1.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech) Generated by OpenAPI Generator (https://openapi-generator.tech)
-} -}
@ -64,19 +64,17 @@ import qualified Prelude as P
-- Test serialization of outer boolean types -- Test serialization of outer boolean types
-- --
fakeOuterBooleanSerialize fakeOuterBooleanSerialize
:: (Consumes FakeOuterBooleanSerialize MimeJSON) :: (Consumes FakeOuterBooleanSerialize contentType)
=> Accept accept -- ^ request accept ('MimeType') => ContentType contentType -- ^ request content-type ('MimeType')
-> OpenAPIPetstoreRequest FakeOuterBooleanSerialize MimeJSON Bool accept -> Accept accept -- ^ request accept ('MimeType')
fakeOuterBooleanSerialize _ = -> OpenAPIPetstoreRequest FakeOuterBooleanSerialize contentType Bool accept
fakeOuterBooleanSerialize _ _ =
_mkRequest "POST" ["/fake/outer/boolean"] _mkRequest "POST" ["/fake/outer/boolean"]
data FakeOuterBooleanSerialize data FakeOuterBooleanSerialize
-- | /Body Param/ "body" - Input boolean as post body -- | /Body Param/ "body" - Input boolean as post body
instance HasBodyParam FakeOuterBooleanSerialize Body8 instance HasBodyParam FakeOuterBooleanSerialize BodyBool
-- | @application/json@
instance Consumes FakeOuterBooleanSerialize MimeJSON
-- | @*/*@ -- | @*/*@
instance MimeType mtype => Produces FakeOuterBooleanSerialize mtype instance MimeType mtype => Produces FakeOuterBooleanSerialize mtype
@ -89,10 +87,11 @@ instance MimeType mtype => Produces FakeOuterBooleanSerialize mtype
-- Test serialization of object with outer number type -- Test serialization of object with outer number type
-- --
fakeOuterCompositeSerialize fakeOuterCompositeSerialize
:: (Consumes FakeOuterCompositeSerialize MimeJSON) :: (Consumes FakeOuterCompositeSerialize contentType)
=> Accept accept -- ^ request accept ('MimeType') => ContentType contentType -- ^ request content-type ('MimeType')
-> OpenAPIPetstoreRequest FakeOuterCompositeSerialize MimeJSON OuterComposite accept -> Accept accept -- ^ request accept ('MimeType')
fakeOuterCompositeSerialize _ = -> OpenAPIPetstoreRequest FakeOuterCompositeSerialize contentType OuterComposite accept
fakeOuterCompositeSerialize _ _ =
_mkRequest "POST" ["/fake/outer/composite"] _mkRequest "POST" ["/fake/outer/composite"]
data FakeOuterCompositeSerialize data FakeOuterCompositeSerialize
@ -100,9 +99,6 @@ data FakeOuterCompositeSerialize
-- | /Body Param/ "OuterComposite" - Input composite as post body -- | /Body Param/ "OuterComposite" - Input composite as post body
instance HasBodyParam FakeOuterCompositeSerialize OuterComposite instance HasBodyParam FakeOuterCompositeSerialize OuterComposite
-- | @application/json@
instance Consumes FakeOuterCompositeSerialize MimeJSON
-- | @*/*@ -- | @*/*@
instance MimeType mtype => Produces FakeOuterCompositeSerialize mtype instance MimeType mtype => Produces FakeOuterCompositeSerialize mtype
@ -114,19 +110,17 @@ instance MimeType mtype => Produces FakeOuterCompositeSerialize mtype
-- Test serialization of outer number types -- Test serialization of outer number types
-- --
fakeOuterNumberSerialize fakeOuterNumberSerialize
:: (Consumes FakeOuterNumberSerialize MimeJSON) :: (Consumes FakeOuterNumberSerialize contentType)
=> Accept accept -- ^ request accept ('MimeType') => ContentType contentType -- ^ request content-type ('MimeType')
-> OpenAPIPetstoreRequest FakeOuterNumberSerialize MimeJSON Double accept -> Accept accept -- ^ request accept ('MimeType')
fakeOuterNumberSerialize _ = -> OpenAPIPetstoreRequest FakeOuterNumberSerialize contentType Double accept
fakeOuterNumberSerialize _ _ =
_mkRequest "POST" ["/fake/outer/number"] _mkRequest "POST" ["/fake/outer/number"]
data FakeOuterNumberSerialize data FakeOuterNumberSerialize
-- | /Body Param/ "body" - Input number as post body -- | /Body Param/ "body" - Input number as post body
instance HasBodyParam FakeOuterNumberSerialize Body6 instance HasBodyParam FakeOuterNumberSerialize Body
-- | @application/json@
instance Consumes FakeOuterNumberSerialize MimeJSON
-- | @*/*@ -- | @*/*@
instance MimeType mtype => Produces FakeOuterNumberSerialize mtype instance MimeType mtype => Produces FakeOuterNumberSerialize mtype
@ -139,19 +133,17 @@ instance MimeType mtype => Produces FakeOuterNumberSerialize mtype
-- Test serialization of outer string types -- Test serialization of outer string types
-- --
fakeOuterStringSerialize fakeOuterStringSerialize
:: (Consumes FakeOuterStringSerialize MimeJSON) :: (Consumes FakeOuterStringSerialize contentType)
=> Accept accept -- ^ request accept ('MimeType') => ContentType contentType -- ^ request content-type ('MimeType')
-> OpenAPIPetstoreRequest FakeOuterStringSerialize MimeJSON Text accept -> Accept accept -- ^ request accept ('MimeType')
fakeOuterStringSerialize _ = -> OpenAPIPetstoreRequest FakeOuterStringSerialize contentType Text accept
fakeOuterStringSerialize _ _ =
_mkRequest "POST" ["/fake/outer/string"] _mkRequest "POST" ["/fake/outer/string"]
data FakeOuterStringSerialize data FakeOuterStringSerialize
-- | /Body Param/ "body" - Input string as post body -- | /Body Param/ "body" - Input string as post body
instance HasBodyParam FakeOuterStringSerialize Body7 instance HasBodyParam FakeOuterStringSerialize BodyText
-- | @application/json@
instance Consumes FakeOuterStringSerialize MimeJSON
-- | @*/*@ -- | @*/*@
instance MimeType mtype => Produces FakeOuterStringSerialize mtype instance MimeType mtype => Produces FakeOuterStringSerialize mtype
@ -353,7 +345,7 @@ instance HasOptionalParam TestEnumParameters EnumHeaderString where
-- | /Optional Param/ "enum_query_string_array" - Query parameter enum test (string array) -- | /Optional Param/ "enum_query_string_array" - Query parameter enum test (string array)
instance HasOptionalParam TestEnumParameters EnumQueryStringArray where instance HasOptionalParam TestEnumParameters EnumQueryStringArray where
applyOptionalParam req (EnumQueryStringArray xs) = applyOptionalParam req (EnumQueryStringArray xs) =
req `setQuery` toQueryColl MultiParamArray ("enum_query_string_array", Just xs) req `setQuery` toQueryColl CommaSeparated ("enum_query_string_array", Just xs)
-- | /Optional Param/ "enum_query_string" - Query parameter enum test (string) -- | /Optional Param/ "enum_query_string" - Query parameter enum test (string)
instance HasOptionalParam TestEnumParameters EnumQueryString where instance HasOptionalParam TestEnumParameters EnumQueryString where

View File

@ -3,7 +3,7 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI Version: 3.0.0 OpenAPI Version: 3.0.1
OpenAPI Petstore API version: 1.0.0 OpenAPI Petstore API version: 1.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech) Generated by OpenAPI Generator (https://openapi-generator.tech)
-} -}

View File

@ -3,7 +3,7 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI Version: 3.0.0 OpenAPI Version: 3.0.1
OpenAPI Petstore API version: 1.0.0 OpenAPI Petstore API version: 1.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech) Generated by OpenAPI Generator (https://openapi-generator.tech)
-} -}

View File

@ -3,7 +3,7 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI Version: 3.0.0 OpenAPI Version: 3.0.1
OpenAPI Petstore API version: 1.0.0 OpenAPI Petstore API version: 1.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech) Generated by OpenAPI Generator (https://openapi-generator.tech)
-} -}
@ -128,11 +128,12 @@ instance Produces GetOrderById MimeJSON
-- Place an order for a pet -- Place an order for a pet
-- --
placeOrder placeOrder
:: (Consumes PlaceOrder MimeJSON, MimeRender MimeJSON Order) :: (Consumes PlaceOrder contentType, MimeRender contentType Order)
=> Accept accept -- ^ request accept ('MimeType') => ContentType contentType -- ^ request content-type ('MimeType')
-> Accept accept -- ^ request accept ('MimeType')
-> Order -- ^ "order" - order placed for purchasing the pet -> Order -- ^ "order" - order placed for purchasing the pet
-> OpenAPIPetstoreRequest PlaceOrder MimeJSON Order accept -> OpenAPIPetstoreRequest PlaceOrder contentType Order accept
placeOrder _ order = placeOrder _ _ order =
_mkRequest "POST" ["/store/order"] _mkRequest "POST" ["/store/order"]
`setBodyParam` order `setBodyParam` order
@ -141,9 +142,6 @@ data PlaceOrder
-- | /Body Param/ "Order" - order placed for purchasing the pet -- | /Body Param/ "Order" - order placed for purchasing the pet
instance HasBodyParam PlaceOrder Order instance HasBodyParam PlaceOrder Order
-- | @application/json@
instance Consumes PlaceOrder MimeJSON
-- | @application/xml@ -- | @application/xml@
instance Produces PlaceOrder MimeXML instance Produces PlaceOrder MimeXML
-- | @application/json@ -- | @application/json@

View File

@ -3,7 +3,7 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI Version: 3.0.0 OpenAPI Version: 3.0.1
OpenAPI Petstore API version: 1.0.0 OpenAPI Petstore API version: 1.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech) Generated by OpenAPI Generator (https://openapi-generator.tech)
-} -}
@ -66,10 +66,11 @@ import qualified Prelude as P
-- This can only be done by the logged in user. -- This can only be done by the logged in user.
-- --
createUser createUser
:: (Consumes CreateUser MimeJSON, MimeRender MimeJSON User) :: (Consumes CreateUser contentType, MimeRender contentType User)
=> User -- ^ "user" - Created user object => ContentType contentType -- ^ request content-type ('MimeType')
-> OpenAPIPetstoreRequest CreateUser MimeJSON NoContent MimeNoContent -> User -- ^ "user" - Created user object
createUser user = -> OpenAPIPetstoreRequest CreateUser contentType NoContent MimeNoContent
createUser _ user =
_mkRequest "POST" ["/user"] _mkRequest "POST" ["/user"]
`setBodyParam` user `setBodyParam` user
@ -78,9 +79,6 @@ data CreateUser
-- | /Body Param/ "User" - Created user object -- | /Body Param/ "User" - Created user object
instance HasBodyParam CreateUser User instance HasBodyParam CreateUser User
-- | @application/json@
instance Consumes CreateUser MimeJSON
instance Produces CreateUser MimeNoContent instance Produces CreateUser MimeNoContent
@ -91,10 +89,11 @@ instance Produces CreateUser MimeNoContent
-- Creates list of users with given input array -- Creates list of users with given input array
-- --
createUsersWithArrayInput createUsersWithArrayInput
:: (Consumes CreateUsersWithArrayInput MimeJSON, MimeRender MimeJSON User2) :: (Consumes CreateUsersWithArrayInput contentType, MimeRender contentType User2)
=> User2 -- ^ "user" - List of user object => ContentType contentType -- ^ request content-type ('MimeType')
-> OpenAPIPetstoreRequest CreateUsersWithArrayInput MimeJSON NoContent MimeNoContent -> User2 -- ^ "user" - List of user object
createUsersWithArrayInput user = -> OpenAPIPetstoreRequest CreateUsersWithArrayInput contentType NoContent MimeNoContent
createUsersWithArrayInput _ user =
_mkRequest "POST" ["/user/createWithArray"] _mkRequest "POST" ["/user/createWithArray"]
`setBodyParam` user `setBodyParam` user
@ -103,9 +102,6 @@ data CreateUsersWithArrayInput
-- | /Body Param/ "User" - List of user object -- | /Body Param/ "User" - List of user object
instance HasBodyParam CreateUsersWithArrayInput User2 instance HasBodyParam CreateUsersWithArrayInput User2
-- | @application/json@
instance Consumes CreateUsersWithArrayInput MimeJSON
instance Produces CreateUsersWithArrayInput MimeNoContent instance Produces CreateUsersWithArrayInput MimeNoContent
@ -116,10 +112,11 @@ instance Produces CreateUsersWithArrayInput MimeNoContent
-- Creates list of users with given input array -- Creates list of users with given input array
-- --
createUsersWithListInput createUsersWithListInput
:: (Consumes CreateUsersWithListInput MimeJSON, MimeRender MimeJSON User2) :: (Consumes CreateUsersWithListInput contentType, MimeRender contentType User2)
=> User2 -- ^ "user" - List of user object => ContentType contentType -- ^ request content-type ('MimeType')
-> OpenAPIPetstoreRequest CreateUsersWithListInput MimeJSON NoContent MimeNoContent -> User2 -- ^ "user" - List of user object
createUsersWithListInput user = -> OpenAPIPetstoreRequest CreateUsersWithListInput contentType NoContent MimeNoContent
createUsersWithListInput _ user =
_mkRequest "POST" ["/user/createWithList"] _mkRequest "POST" ["/user/createWithList"]
`setBodyParam` user `setBodyParam` user
@ -128,9 +125,6 @@ data CreateUsersWithListInput
-- | /Body Param/ "User" - List of user object -- | /Body Param/ "User" - List of user object
instance HasBodyParam CreateUsersWithListInput User2 instance HasBodyParam CreateUsersWithListInput User2
-- | @application/json@
instance Consumes CreateUsersWithListInput MimeJSON
instance Produces CreateUsersWithListInput MimeNoContent instance Produces CreateUsersWithListInput MimeNoContent
@ -223,11 +217,12 @@ instance Produces LogoutUser MimeNoContent
-- This can only be done by the logged in user. -- This can only be done by the logged in user.
-- --
updateUser updateUser
:: (Consumes UpdateUser MimeJSON, MimeRender MimeJSON User) :: (Consumes UpdateUser contentType, MimeRender contentType User)
=> User -- ^ "user" - Updated user object => ContentType contentType -- ^ request content-type ('MimeType')
-> User -- ^ "user" - Updated user object
-> Username -- ^ "username" - name that need to be deleted -> Username -- ^ "username" - name that need to be deleted
-> OpenAPIPetstoreRequest UpdateUser MimeJSON NoContent MimeNoContent -> OpenAPIPetstoreRequest UpdateUser contentType NoContent MimeNoContent
updateUser user (Username username) = updateUser _ user (Username username) =
_mkRequest "PUT" ["/user/",toPath username] _mkRequest "PUT" ["/user/",toPath username]
`setBodyParam` user `setBodyParam` user
@ -236,8 +231,5 @@ data UpdateUser
-- | /Body Param/ "User" - Updated user object -- | /Body Param/ "User" - Updated user object
instance HasBodyParam UpdateUser User instance HasBodyParam UpdateUser User
-- | @application/json@
instance Consumes UpdateUser MimeJSON
instance Produces UpdateUser MimeNoContent instance Produces UpdateUser MimeNoContent

View File

@ -3,7 +3,7 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI Version: 3.0.0 OpenAPI Version: 3.0.1
OpenAPI Petstore API version: 1.0.0 OpenAPI Petstore API version: 1.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech) Generated by OpenAPI Generator (https://openapi-generator.tech)
-} -}

View File

@ -3,7 +3,7 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI Version: 3.0.0 OpenAPI Version: 3.0.1
OpenAPI Petstore API version: 1.0.0 OpenAPI Petstore API version: 1.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech) Generated by OpenAPI Generator (https://openapi-generator.tech)
-} -}

View File

@ -3,7 +3,7 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI Version: 3.0.0 OpenAPI Version: 3.0.1
OpenAPI Petstore API version: 1.0.0 OpenAPI Petstore API version: 1.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech) Generated by OpenAPI Generator (https://openapi-generator.tech)
-} -}

View File

@ -3,7 +3,7 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI Version: 3.0.0 OpenAPI Version: 3.0.1
OpenAPI Petstore API version: 1.0.0 OpenAPI Petstore API version: 1.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech) Generated by OpenAPI Generator (https://openapi-generator.tech)
-} -}

View File

@ -3,7 +3,7 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI Version: 3.0.0 OpenAPI Version: 3.0.1
OpenAPI Petstore API version: 1.0.0 OpenAPI Petstore API version: 1.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech) Generated by OpenAPI Generator (https://openapi-generator.tech)
-} -}
@ -72,14 +72,14 @@ newtype AdditionalMetadata = AdditionalMetadata { unAdditionalMetadata :: Text }
-- ** ApiKey -- ** ApiKey
newtype ApiKey = ApiKey { unApiKey :: Text } deriving (P.Eq, P.Show) newtype ApiKey = ApiKey { unApiKey :: Text } deriving (P.Eq, P.Show)
-- ** Body6 -- ** Body
newtype Body6 = Body6 { unBody6 :: Double } deriving (P.Eq, P.Show, A.ToJSON) newtype Body = Body { unBody :: Double } deriving (P.Eq, P.Show, A.ToJSON)
-- ** Body7 -- ** BodyBool
newtype Body7 = Body7 { unBody7 :: Text } deriving (P.Eq, P.Show, A.ToJSON) newtype BodyBool = BodyBool { unBodyBool :: Bool } deriving (P.Eq, P.Show, A.ToJSON)
-- ** Body8 -- ** BodyText
newtype Body8 = Body8 { unBody8 :: Bool } deriving (P.Eq, P.Show, A.ToJSON) newtype BodyText = BodyText { unBodyText :: Text } deriving (P.Eq, P.Show, A.ToJSON)
-- ** Byte -- ** Byte
newtype Byte = Byte { unByte :: ByteArray } deriving (P.Eq, P.Show) newtype Byte = Byte { unByte :: ByteArray } deriving (P.Eq, P.Show)
@ -416,253 +416,6 @@ mkArrayTest =
, arrayTestArrayArrayOfModel = Nothing , arrayTestArrayArrayOfModel = Nothing
} }
-- ** Body
-- | Body
data Body = Body
{ bodyName :: !(Maybe Text) -- ^ "name" - Updated name of the pet
, bodyStatus :: !(Maybe Text) -- ^ "status" - Updated status of the pet
} deriving (P.Show, P.Eq, P.Typeable)
-- | FromJSON Body
instance A.FromJSON Body where
parseJSON = A.withObject "Body" $ \o ->
Body
<$> (o .:? "name")
<*> (o .:? "status")
-- | ToJSON Body
instance A.ToJSON Body where
toJSON Body {..} =
_omitNulls
[ "name" .= bodyName
, "status" .= bodyStatus
]
-- | Construct a value of type 'Body' (by applying it's required fields, if any)
mkBody
:: Body
mkBody =
Body
{ bodyName = Nothing
, bodyStatus = Nothing
}
-- ** Body1
-- | Body1
data Body1 = Body1
{ body1AdditionalMetadata :: !(Maybe Text) -- ^ "additionalMetadata" - Additional data to pass to server
, body1File :: !(Maybe FilePath) -- ^ "file" - file to upload
} deriving (P.Show, P.Eq, P.Typeable)
-- | FromJSON Body1
instance A.FromJSON Body1 where
parseJSON = A.withObject "Body1" $ \o ->
Body1
<$> (o .:? "additionalMetadata")
<*> (o .:? "file")
-- | ToJSON Body1
instance A.ToJSON Body1 where
toJSON Body1 {..} =
_omitNulls
[ "additionalMetadata" .= body1AdditionalMetadata
, "file" .= body1File
]
-- | Construct a value of type 'Body1' (by applying it's required fields, if any)
mkBody1
:: Body1
mkBody1 =
Body1
{ body1AdditionalMetadata = Nothing
, body1File = Nothing
}
-- ** Body2
-- | Body2
data Body2 = Body2
{ body2EnumFormStringArray :: !(Maybe [E'EnumFormStringArray]) -- ^ "enum_form_string_array" - Form parameter enum test (string array)
, body2EnumFormString :: !(Maybe E'EnumFormString) -- ^ "enum_form_string" - Form parameter enum test (string)
} deriving (P.Show, P.Eq, P.Typeable)
-- | FromJSON Body2
instance A.FromJSON Body2 where
parseJSON = A.withObject "Body2" $ \o ->
Body2
<$> (o .:? "enum_form_string_array")
<*> (o .:? "enum_form_string")
-- | ToJSON Body2
instance A.ToJSON Body2 where
toJSON Body2 {..} =
_omitNulls
[ "enum_form_string_array" .= body2EnumFormStringArray
, "enum_form_string" .= body2EnumFormString
]
-- | Construct a value of type 'Body2' (by applying it's required fields, if any)
mkBody2
:: Body2
mkBody2 =
Body2
{ body2EnumFormStringArray = Nothing
, body2EnumFormString = Nothing
}
-- ** Body3
-- | Body3
data Body3 = Body3
{ body3Integer :: !(Maybe Int) -- ^ "integer" - None
, body3Int32 :: !(Maybe Int) -- ^ "int32" - None
, body3Int64 :: !(Maybe Integer) -- ^ "int64" - None
, body3Number :: !(Double) -- ^ /Required/ "number" - None
, body3Float :: !(Maybe Float) -- ^ "float" - None
, body3Double :: !(Double) -- ^ /Required/ "double" - None
, body3String :: !(Maybe Text) -- ^ "string" - None
, body3PatternWithoutDelimiter :: !(Text) -- ^ /Required/ "pattern_without_delimiter" - None
, body3Byte :: !(ByteArray) -- ^ /Required/ "byte" - None
, body3Binary :: !(Maybe FilePath) -- ^ "binary" - None
, body3Date :: !(Maybe Date) -- ^ "date" - None
, body3DateTime :: !(Maybe DateTime) -- ^ "dateTime" - None
, body3Password :: !(Maybe Text) -- ^ "password" - None
, body3Callback :: !(Maybe Text) -- ^ "callback" - None
} deriving (P.Show, P.Eq, P.Typeable)
-- | FromJSON Body3
instance A.FromJSON Body3 where
parseJSON = A.withObject "Body3" $ \o ->
Body3
<$> (o .:? "integer")
<*> (o .:? "int32")
<*> (o .:? "int64")
<*> (o .: "number")
<*> (o .:? "float")
<*> (o .: "double")
<*> (o .:? "string")
<*> (o .: "pattern_without_delimiter")
<*> (o .: "byte")
<*> (o .:? "binary")
<*> (o .:? "date")
<*> (o .:? "dateTime")
<*> (o .:? "password")
<*> (o .:? "callback")
-- | ToJSON Body3
instance A.ToJSON Body3 where
toJSON Body3 {..} =
_omitNulls
[ "integer" .= body3Integer
, "int32" .= body3Int32
, "int64" .= body3Int64
, "number" .= body3Number
, "float" .= body3Float
, "double" .= body3Double
, "string" .= body3String
, "pattern_without_delimiter" .= body3PatternWithoutDelimiter
, "byte" .= body3Byte
, "binary" .= body3Binary
, "date" .= body3Date
, "dateTime" .= body3DateTime
, "password" .= body3Password
, "callback" .= body3Callback
]
-- | Construct a value of type 'Body3' (by applying it's required fields, if any)
mkBody3
:: Double -- ^ 'body3Number': None
-> Double -- ^ 'body3Double': None
-> Text -- ^ 'body3PatternWithoutDelimiter': None
-> ByteArray -- ^ 'body3Byte': None
-> Body3
mkBody3 body3Number body3Double body3PatternWithoutDelimiter body3Byte =
Body3
{ body3Integer = Nothing
, body3Int32 = Nothing
, body3Int64 = Nothing
, body3Number
, body3Float = Nothing
, body3Double
, body3String = Nothing
, body3PatternWithoutDelimiter
, body3Byte
, body3Binary = Nothing
, body3Date = Nothing
, body3DateTime = Nothing
, body3Password = Nothing
, body3Callback = Nothing
}
-- ** Body4
-- | Body4
data Body4 = Body4
{ body4Param :: !(Text) -- ^ /Required/ "param" - field1
, body4Param2 :: !(Text) -- ^ /Required/ "param2" - field2
} deriving (P.Show, P.Eq, P.Typeable)
-- | FromJSON Body4
instance A.FromJSON Body4 where
parseJSON = A.withObject "Body4" $ \o ->
Body4
<$> (o .: "param")
<*> (o .: "param2")
-- | ToJSON Body4
instance A.ToJSON Body4 where
toJSON Body4 {..} =
_omitNulls
[ "param" .= body4Param
, "param2" .= body4Param2
]
-- | Construct a value of type 'Body4' (by applying it's required fields, if any)
mkBody4
:: Text -- ^ 'body4Param': field1
-> Text -- ^ 'body4Param2': field2
-> Body4
mkBody4 body4Param body4Param2 =
Body4
{ body4Param
, body4Param2
}
-- ** Body5
-- | Body5
data Body5 = Body5
{ body5AdditionalMetadata :: !(Maybe Text) -- ^ "additionalMetadata" - Additional data to pass to server
, body5RequiredFile :: !(FilePath) -- ^ /Required/ "requiredFile" - file to upload
} deriving (P.Show, P.Eq, P.Typeable)
-- | FromJSON Body5
instance A.FromJSON Body5 where
parseJSON = A.withObject "Body5" $ \o ->
Body5
<$> (o .:? "additionalMetadata")
<*> (o .: "requiredFile")
-- | ToJSON Body5
instance A.ToJSON Body5 where
toJSON Body5 {..} =
_omitNulls
[ "additionalMetadata" .= body5AdditionalMetadata
, "requiredFile" .= body5RequiredFile
]
-- | Construct a value of type 'Body5' (by applying it's required fields, if any)
mkBody5
:: FilePath -- ^ 'body5RequiredFile': file to upload
-> Body5
mkBody5 body5RequiredFile =
Body5
{ body5AdditionalMetadata = Nothing
, body5RequiredFile
}
-- ** Capitalization -- ** Capitalization
-- | Capitalization -- | Capitalization
data Capitalization = Capitalization data Capitalization = Capitalization

View File

@ -3,7 +3,7 @@
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI Version: 3.0.0 OpenAPI Version: 3.0.1
OpenAPI Petstore API version: 1.0.0 OpenAPI Petstore API version: 1.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech) Generated by OpenAPI Generator (https://openapi-generator.tech)
-} -}
@ -124,150 +124,6 @@ arrayTestArrayArrayOfModelL f ArrayTest{..} = (\arrayTestArrayArrayOfModel -> Ar
-- * Body
-- | 'bodyName' Lens
bodyNameL :: Lens_' Body (Maybe Text)
bodyNameL f Body{..} = (\bodyName -> Body { bodyName, ..} ) <$> f bodyName
{-# INLINE bodyNameL #-}
-- | 'bodyStatus' Lens
bodyStatusL :: Lens_' Body (Maybe Text)
bodyStatusL f Body{..} = (\bodyStatus -> Body { bodyStatus, ..} ) <$> f bodyStatus
{-# INLINE bodyStatusL #-}
-- * Body1
-- | 'body1AdditionalMetadata' Lens
body1AdditionalMetadataL :: Lens_' Body1 (Maybe Text)
body1AdditionalMetadataL f Body1{..} = (\body1AdditionalMetadata -> Body1 { body1AdditionalMetadata, ..} ) <$> f body1AdditionalMetadata
{-# INLINE body1AdditionalMetadataL #-}
-- | 'body1File' Lens
body1FileL :: Lens_' Body1 (Maybe FilePath)
body1FileL f Body1{..} = (\body1File -> Body1 { body1File, ..} ) <$> f body1File
{-# INLINE body1FileL #-}
-- * Body2
-- | 'body2EnumFormStringArray' Lens
body2EnumFormStringArrayL :: Lens_' Body2 (Maybe [E'EnumFormStringArray])
body2EnumFormStringArrayL f Body2{..} = (\body2EnumFormStringArray -> Body2 { body2EnumFormStringArray, ..} ) <$> f body2EnumFormStringArray
{-# INLINE body2EnumFormStringArrayL #-}
-- | 'body2EnumFormString' Lens
body2EnumFormStringL :: Lens_' Body2 (Maybe E'EnumFormString)
body2EnumFormStringL f Body2{..} = (\body2EnumFormString -> Body2 { body2EnumFormString, ..} ) <$> f body2EnumFormString
{-# INLINE body2EnumFormStringL #-}
-- * Body3
-- | 'body3Integer' Lens
body3IntegerL :: Lens_' Body3 (Maybe Int)
body3IntegerL f Body3{..} = (\body3Integer -> Body3 { body3Integer, ..} ) <$> f body3Integer
{-# INLINE body3IntegerL #-}
-- | 'body3Int32' Lens
body3Int32L :: Lens_' Body3 (Maybe Int)
body3Int32L f Body3{..} = (\body3Int32 -> Body3 { body3Int32, ..} ) <$> f body3Int32
{-# INLINE body3Int32L #-}
-- | 'body3Int64' Lens
body3Int64L :: Lens_' Body3 (Maybe Integer)
body3Int64L f Body3{..} = (\body3Int64 -> Body3 { body3Int64, ..} ) <$> f body3Int64
{-# INLINE body3Int64L #-}
-- | 'body3Number' Lens
body3NumberL :: Lens_' Body3 (Double)
body3NumberL f Body3{..} = (\body3Number -> Body3 { body3Number, ..} ) <$> f body3Number
{-# INLINE body3NumberL #-}
-- | 'body3Float' Lens
body3FloatL :: Lens_' Body3 (Maybe Float)
body3FloatL f Body3{..} = (\body3Float -> Body3 { body3Float, ..} ) <$> f body3Float
{-# INLINE body3FloatL #-}
-- | 'body3Double' Lens
body3DoubleL :: Lens_' Body3 (Double)
body3DoubleL f Body3{..} = (\body3Double -> Body3 { body3Double, ..} ) <$> f body3Double
{-# INLINE body3DoubleL #-}
-- | 'body3String' Lens
body3StringL :: Lens_' Body3 (Maybe Text)
body3StringL f Body3{..} = (\body3String -> Body3 { body3String, ..} ) <$> f body3String
{-# INLINE body3StringL #-}
-- | 'body3PatternWithoutDelimiter' Lens
body3PatternWithoutDelimiterL :: Lens_' Body3 (Text)
body3PatternWithoutDelimiterL f Body3{..} = (\body3PatternWithoutDelimiter -> Body3 { body3PatternWithoutDelimiter, ..} ) <$> f body3PatternWithoutDelimiter
{-# INLINE body3PatternWithoutDelimiterL #-}
-- | 'body3Byte' Lens
body3ByteL :: Lens_' Body3 (ByteArray)
body3ByteL f Body3{..} = (\body3Byte -> Body3 { body3Byte, ..} ) <$> f body3Byte
{-# INLINE body3ByteL #-}
-- | 'body3Binary' Lens
body3BinaryL :: Lens_' Body3 (Maybe FilePath)
body3BinaryL f Body3{..} = (\body3Binary -> Body3 { body3Binary, ..} ) <$> f body3Binary
{-# INLINE body3BinaryL #-}
-- | 'body3Date' Lens
body3DateL :: Lens_' Body3 (Maybe Date)
body3DateL f Body3{..} = (\body3Date -> Body3 { body3Date, ..} ) <$> f body3Date
{-# INLINE body3DateL #-}
-- | 'body3DateTime' Lens
body3DateTimeL :: Lens_' Body3 (Maybe DateTime)
body3DateTimeL f Body3{..} = (\body3DateTime -> Body3 { body3DateTime, ..} ) <$> f body3DateTime
{-# INLINE body3DateTimeL #-}
-- | 'body3Password' Lens
body3PasswordL :: Lens_' Body3 (Maybe Text)
body3PasswordL f Body3{..} = (\body3Password -> Body3 { body3Password, ..} ) <$> f body3Password
{-# INLINE body3PasswordL #-}
-- | 'body3Callback' Lens
body3CallbackL :: Lens_' Body3 (Maybe Text)
body3CallbackL f Body3{..} = (\body3Callback -> Body3 { body3Callback, ..} ) <$> f body3Callback
{-# INLINE body3CallbackL #-}
-- * Body4
-- | 'body4Param' Lens
body4ParamL :: Lens_' Body4 (Text)
body4ParamL f Body4{..} = (\body4Param -> Body4 { body4Param, ..} ) <$> f body4Param
{-# INLINE body4ParamL #-}
-- | 'body4Param2' Lens
body4Param2L :: Lens_' Body4 (Text)
body4Param2L f Body4{..} = (\body4Param2 -> Body4 { body4Param2, ..} ) <$> f body4Param2
{-# INLINE body4Param2L #-}
-- * Body5
-- | 'body5AdditionalMetadata' Lens
body5AdditionalMetadataL :: Lens_' Body5 (Maybe Text)
body5AdditionalMetadataL f Body5{..} = (\body5AdditionalMetadata -> Body5 { body5AdditionalMetadata, ..} ) <$> f body5AdditionalMetadata
{-# INLINE body5AdditionalMetadataL #-}
-- | 'body5RequiredFile' Lens
body5RequiredFileL :: Lens_' Body5 (FilePath)
body5RequiredFileL f Body5{..} = (\body5RequiredFile -> Body5 { body5RequiredFile, ..} ) <$> f body5RequiredFile
{-# INLINE body5RequiredFileL #-}
-- * Capitalization -- * Capitalization
-- | 'capitalizationSmallCamel' Lens -- | 'capitalizationSmallCamel' Lens

View File

@ -10,7 +10,7 @@ description: .
. .
OpenAPI Petstore API version: 1.0.0 OpenAPI Petstore API version: 1.0.0
. .
OpenAPI version: 3.0.0 OpenAPI version: 3.0.1
. .
category: Web category: Web
homepage: https://openapi-generator.tech homepage: https://openapi-generator.tech

File diff suppressed because it is too large Load Diff

View File

@ -164,6 +164,7 @@ testPetOps mgr config =
-- * STORE TESTS -- * STORE TESTS
instance S.Consumes S.PlaceOrder S.MimeJSON
testStoreOps :: NH.Manager -> S.OpenAPIPetstoreConfig -> Spec testStoreOps :: NH.Manager -> S.OpenAPIPetstoreConfig -> Spec
testStoreOps mgr config = do testStoreOps mgr config = do
@ -183,7 +184,7 @@ testStoreOps mgr config = do
it "placeOrder" $ do it "placeOrder" $ do
now <- TI.getCurrentTime now <- TI.getCurrentTime
let placeOrderRequest = S.placeOrder (S.Accept S.MimeJSON) let placeOrderRequest = S.placeOrder (S.ContentType S.MimeJSON) (S.Accept S.MimeJSON)
(S.mkOrder (S.mkOrder
{ S.orderId = Just 21 { S.orderId = Just 21
, S.orderQuantity = Just 210 , S.orderQuantity = Just 210
@ -221,6 +222,11 @@ testStoreOps mgr config = do
-- * USER TESTS -- * USER TESTS
instance S.Consumes S.CreateUser S.MimeJSON
instance S.Consumes S.CreateUsersWithArrayInput S.MimeJSON
instance S.Consumes S.CreateUsersWithListInput S.MimeJSON
instance S.Consumes S.UpdateUser S.MimeJSON
testUserOps :: NH.Manager -> S.OpenAPIPetstoreConfig -> Spec testUserOps :: NH.Manager -> S.OpenAPIPetstoreConfig -> Spec
testUserOps mgr config = do testUserOps mgr config = do
@ -245,19 +251,19 @@ testUserOps mgr config = do
before (pure _user) $ before (pure _user) $
it "createUser" $ \user -> do it "createUser" $ \user -> do
let createUserRequest = S.createUser user let createUserRequest = S.createUser (S.ContentType S.MimeJSON) user
createUserResult <- S.dispatchLbs mgr config createUserRequest createUserResult <- S.dispatchLbs mgr config createUserRequest
NH.responseStatus createUserResult `shouldBe` NH.status200 NH.responseStatus createUserResult `shouldBe` NH.status200
before (pure _users) $ before (pure _users) $
it "createUsersWithArrayInput" $ \users -> do it "createUsersWithArrayInput" $ \users -> do
let createUsersWithArrayInputRequest = S.createUsersWithArrayInput (S.User2 users) let createUsersWithArrayInputRequest = S.createUsersWithArrayInput (S.ContentType S.MimeJSON) (S.User2 users)
createUsersWithArrayInputResult <- S.dispatchLbs mgr config createUsersWithArrayInputRequest createUsersWithArrayInputResult <- S.dispatchLbs mgr config createUsersWithArrayInputRequest
NH.responseStatus createUsersWithArrayInputResult `shouldBe` NH.status200 NH.responseStatus createUsersWithArrayInputResult `shouldBe` NH.status200
before (pure _users) $ before (pure _users) $
it "createUsersWithListInput" $ \users -> do it "createUsersWithListInput" $ \users -> do
let createUsersWithListInputRequest = S.createUsersWithListInput (S.User2 users) let createUsersWithListInputRequest = S.createUsersWithListInput (S.ContentType S.MimeJSON) (S.User2 users)
createUsersWithListInputResult <- S.dispatchLbs mgr config createUsersWithListInputRequest createUsersWithListInputResult <- S.dispatchLbs mgr config createUsersWithListInputRequest
NH.responseStatus createUsersWithListInputResult `shouldBe` NH.status200 NH.responseStatus createUsersWithListInputResult `shouldBe` NH.status200
@ -278,7 +284,7 @@ testUserOps mgr config = do
before (pure (_username, _user)) $ before (pure (_username, _user)) $
it "updateUser" $ \(username, user) -> do it "updateUser" $ \(username, user) -> do
let updateUserRequest = S.updateUser user (S.Username username) let updateUserRequest = S.updateUser (S.ContentType S.MimeJSON) user (S.Username username)
updateUserResult <- S.dispatchLbs mgr config updateUserRequest updateUserResult <- S.dispatchLbs mgr config updateUserRequest
NH.responseStatus updateUserResult `shouldBe` NH.status200 NH.responseStatus updateUserResult `shouldBe` NH.status200

View File

@ -130,54 +130,6 @@ instance Arbitrary ArrayTest where
<*> arbitrary -- arrayTestArrayArrayOfInteger :: Maybe [[Integer]] <*> arbitrary -- arrayTestArrayArrayOfInteger :: Maybe [[Integer]]
<*> arbitrary -- arrayTestArrayArrayOfModel :: Maybe [[ReadOnlyFirst]] <*> arbitrary -- arrayTestArrayArrayOfModel :: Maybe [[ReadOnlyFirst]]
instance Arbitrary Body where
arbitrary =
Body
<$> arbitrary -- bodyName :: Maybe Text
<*> arbitrary -- bodyStatus :: Maybe Text
instance Arbitrary Body1 where
arbitrary =
Body1
<$> arbitrary -- body1AdditionalMetadata :: Maybe Text
<*> arbitrary -- body1File :: Maybe FilePath
instance Arbitrary Body2 where
arbitrary =
Body2
<$> arbitrary -- body2EnumFormStringArray :: Maybe [Text]
<*> arbitrary -- body2EnumFormString :: Maybe Text
instance Arbitrary Body3 where
arbitrary =
Body3
<$> arbitrary -- body3Integer :: Maybe Int
<*> arbitrary -- body3Int32 :: Maybe Int
<*> arbitrary -- body3Int64 :: Maybe Integer
<*> arbitrary -- body3Number :: Double
<*> arbitrary -- body3Float :: Maybe Float
<*> arbitrary -- body3Double :: Double
<*> arbitrary -- body3String :: Maybe Text
<*> arbitrary -- body3PatternWithoutDelimiter :: Text
<*> arbitrary -- body3Byte :: ByteArray
<*> arbitrary -- body3Binary :: Maybe FilePath
<*> arbitrary -- body3Date :: Maybe Date
<*> arbitrary -- body3DateTime :: Maybe DateTime
<*> arbitrary -- body3Password :: Maybe Text
<*> arbitrary -- body3Callback :: Maybe Text
instance Arbitrary Body4 where
arbitrary =
Body4
<$> arbitrary -- body4Param :: Text
<*> arbitrary -- body4Param2 :: Text
instance Arbitrary Body5 where
arbitrary =
Body5
<$> arbitrary -- body5AdditionalMetadata :: Maybe Text
<*> arbitrary -- body5RequiredFile :: FilePath
instance Arbitrary Capitalization where instance Arbitrary Capitalization where
arbitrary = arbitrary =
Capitalization Capitalization

View File

@ -27,12 +27,6 @@ main =
propMimeEq MimeJSON (Proxy :: Proxy ArrayOfArrayOfNumberOnly) propMimeEq MimeJSON (Proxy :: Proxy ArrayOfArrayOfNumberOnly)
propMimeEq MimeJSON (Proxy :: Proxy ArrayOfNumberOnly) propMimeEq MimeJSON (Proxy :: Proxy ArrayOfNumberOnly)
propMimeEq MimeJSON (Proxy :: Proxy ArrayTest) propMimeEq MimeJSON (Proxy :: Proxy ArrayTest)
propMimeEq MimeJSON (Proxy :: Proxy Body)
propMimeEq MimeJSON (Proxy :: Proxy Body1)
propMimeEq MimeJSON (Proxy :: Proxy Body2)
propMimeEq MimeJSON (Proxy :: Proxy Body3)
propMimeEq MimeJSON (Proxy :: Proxy Body4)
propMimeEq MimeJSON (Proxy :: Proxy Body5)
propMimeEq MimeJSON (Proxy :: Proxy Capitalization) propMimeEq MimeJSON (Proxy :: Proxy Capitalization)
propMimeEq MimeJSON (Proxy :: Proxy Cat) propMimeEq MimeJSON (Proxy :: Proxy Cat)
propMimeEq MimeJSON (Proxy :: Proxy Category) propMimeEq MimeJSON (Proxy :: Proxy Category)

View File

@ -1 +1 @@
3.0.0-SNAPSHOT 3.3.0-SNAPSHOT