forked from loafle/openapi-generator-original
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:
parent
f1f7bdd23f
commit
cbddb08468
@ -30,7 +30,7 @@ sleep 5
|
||||
./bin/typescript-node-petstore-all.sh > /dev/null 2>&1
|
||||
./bin/typescript-inversify-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/meta-codegen.sh > /dev/null 2>&1
|
||||
./bin/utils/export_docs_generators.sh > /dev/null 2>&1
|
||||
|
@ -24,6 +24,7 @@ import io.swagger.v3.oas.models.media.Schema;
|
||||
import io.swagger.v3.oas.models.security.SecurityScheme;
|
||||
import org.apache.commons.lang3.StringEscapeUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
@ -361,6 +362,10 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
|
||||
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)");
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(PROP_ALLOW_FROMJSON_NULLS)) {
|
||||
setAllowFromJsonNulls(convertPropertyToBoolean(PROP_ALLOW_FROMJSON_NULLS));
|
||||
} else {
|
||||
@ -1345,4 +1350,31 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
|
||||
.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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.Operation;
|
||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.CliOption;
|
||||
import org.openapitools.codegen.CodegenConfig;
|
||||
@ -36,6 +37,7 @@ import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
@ -100,20 +102,20 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
|
||||
// set the output folder here
|
||||
outputFolder = "generated-code/haskell-servant";
|
||||
|
||||
/*
|
||||
* Template Location. This is the location which templates will be read from. The generator
|
||||
* will use the resource stream to attempt to read the templates.
|
||||
*/
|
||||
/*
|
||||
* Template Location. This is the location which templates will be read from. The generator
|
||||
* will use the resource stream to attempt to read the templates.
|
||||
*/
|
||||
embeddedTemplateDir = templateDir = "haskell-servant";
|
||||
|
||||
/*
|
||||
* Api Package. Optional, if needed, this can be used in templates
|
||||
*/
|
||||
/*
|
||||
* Api Package. Optional, if needed, this can be used in templates
|
||||
*/
|
||||
apiPackage = "API";
|
||||
|
||||
/*
|
||||
* Model Package. Optional, if needed, this can be used in templates
|
||||
*/
|
||||
/*
|
||||
* Model Package. Optional, if needed, this can be used in templates
|
||||
*/
|
||||
modelPackage = "Types";
|
||||
|
||||
// Haskell keywords and reserved function names, taken mostly from https://wiki.haskell.org/Keywords
|
||||
@ -133,25 +135,25 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
|
||||
)
|
||||
);
|
||||
|
||||
/*
|
||||
* Additional Properties. These values can be passed to the templates and
|
||||
* are available in models, apis, and supporting files
|
||||
*/
|
||||
/*
|
||||
* Additional Properties. These values can be passed to the templates and
|
||||
* are available in models, apis, and supporting files
|
||||
*/
|
||||
additionalProperties.put("apiVersion", apiVersion);
|
||||
|
||||
/*
|
||||
* Supporting Files. You can write single files for the generator with the
|
||||
* entire object tree available. If the input file has a suffix of `.mustache
|
||||
* it will be processed by the template engine. Otherwise, it will be copied
|
||||
*/
|
||||
/*
|
||||
* Supporting Files. You can write single files for the generator with the
|
||||
* entire object tree available. If the input file has a suffix of `.mustache
|
||||
* it will be processed by the template engine. Otherwise, it will be copied
|
||||
*/
|
||||
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||
supportingFiles.add(new SupportingFile("stack.mustache", "", "stack.yaml"));
|
||||
supportingFiles.add(new SupportingFile("Setup.mustache", "", "Setup.hs"));
|
||||
|
||||
/*
|
||||
* Language Specific Primitives. These types will not trigger imports by
|
||||
* the client generator
|
||||
*/
|
||||
/*
|
||||
* Language Specific Primitives. These types will not trigger imports by
|
||||
* the client generator
|
||||
*/
|
||||
languageSpecificPrimitives = new HashSet<String>(
|
||||
Arrays.asList(
|
||||
"Bool",
|
||||
@ -179,6 +181,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
|
||||
typeMapping.put("double", "Double");
|
||||
typeMapping.put("DateTime", "Integer");
|
||||
typeMapping.put("file", "FilePath");
|
||||
typeMapping.put("binary", "FilePath");
|
||||
typeMapping.put("number", "Double");
|
||||
typeMapping.put("any", "Value");
|
||||
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));
|
||||
}
|
||||
|
||||
@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
|
||||
* 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
|
||||
public String escapeReservedWord(String name) {
|
||||
if(this.reservedWordsMappings().containsKey(name)) {
|
||||
if (this.reservedWordsMappings().containsKey(name)) {
|
||||
return this.reservedWordsMappings().get(name);
|
||||
}
|
||||
return "_" + name;
|
||||
@ -232,7 +244,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
|
||||
String title = openAPI.getInfo().getTitle();
|
||||
|
||||
// Drop any API suffix
|
||||
if(title == null) {
|
||||
if (title == null) {
|
||||
title = "OpenAPI";
|
||||
} else {
|
||||
title = title.trim();
|
||||
@ -272,7 +284,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
|
||||
|
||||
List<Map<String, Object>> replacements = new ArrayList<>();
|
||||
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];
|
||||
Map<String, Object> o = new HashMap<>();
|
||||
o.put("char", c);
|
||||
@ -321,7 +333,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
|
||||
return type;
|
||||
//if (languageSpecificPrimitives.contains(type))
|
||||
// return toModelName(type);
|
||||
} else if(typeMapping.containsValue(schemaType)) {
|
||||
} else if (typeMapping.containsValue(schemaType)) {
|
||||
// TODO what's this case for?
|
||||
type = schemaType + "_";
|
||||
} else {
|
||||
@ -452,7 +464,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
|
||||
path.add("ReqBody '[JSON] " + 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
|
||||
String formName = "Form" + org.openapitools.codegen.utils.StringUtils.camelize(op.operationId);
|
||||
bodyType = formName;
|
||||
@ -496,7 +508,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
|
||||
op.vendorExtensions.put("x-routeType", joinStrings(" :> ", path));
|
||||
op.vendorExtensions.put("x-clientType", joinStrings(" -> ", type));
|
||||
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));
|
||||
}
|
||||
return op;
|
||||
@ -504,12 +516,17 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
|
||||
|
||||
private String makeQueryListType(String type, String collectionFormat) {
|
||||
type = type.substring(1, type.length() - 1);
|
||||
switch(collectionFormat) {
|
||||
case "csv": return "(QueryList 'CommaSeparated (" + type + "))";
|
||||
case "tsv": return "(QueryList 'TabSeparated (" + type + "))";
|
||||
case "ssv": return "(QueryList 'SpaceSeparated (" + type + "))";
|
||||
case "pipes": return "(QueryList 'PipeSeparated (" + type + "))";
|
||||
case "multi": return "(QueryList 'MultiParamArray (" + type + "))";
|
||||
switch (collectionFormat) {
|
||||
case "csv":
|
||||
return "(QueryList 'CommaSeparated (" + type + "))";
|
||||
case "tsv":
|
||||
return "(QueryList 'TabSeparated (" + type + "))";
|
||||
case "ssv":
|
||||
return "(QueryList 'SpaceSeparated (" + type + "))";
|
||||
case "pipes":
|
||||
return "(QueryList 'PipeSeparated (" + type + "))";
|
||||
case "multi":
|
||||
return "(QueryList 'MultiParamArray (" + type + "))";
|
||||
default:
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
@ -550,19 +567,19 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
|
||||
|
||||
// Clean up the class name to remove invalid characters
|
||||
model.classname = fixModelChars(model.classname);
|
||||
if(typeMapping.containsValue(model.classname)) {
|
||||
if (typeMapping.containsValue(model.classname)) {
|
||||
model.classname += "_";
|
||||
}
|
||||
|
||||
// From the model name, compute the prefix for the fields.
|
||||
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)));
|
||||
}
|
||||
|
||||
// Create newtypes for things with non-object types
|
||||
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);
|
||||
model.vendorExtensions.put("x-customNewtype", newtype);
|
||||
}
|
||||
@ -585,4 +602,30 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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.
|
||||
|
||||
OpenApi Version: 3.0.0
|
||||
OpenApi Version: 3.0.1
|
||||
|
||||
## Installation
|
||||
|
||||
|
@ -155,7 +155,8 @@ runPet mgr config = do
|
||||
|
||||
|
||||
-- * STORE
|
||||
|
||||
instance S.Consumes S.PlaceOrder S.MimeJSON
|
||||
|
||||
runStore :: NH.Manager -> S.OpenAPIPetstoreConfig -> IO ()
|
||||
runStore mgr config = do
|
||||
|
||||
@ -167,7 +168,7 @@ runStore mgr config = do
|
||||
|
||||
-- placeOrder
|
||||
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
|
||||
mapM_ (\r -> putStrLn $ "placeOrderResult: " <> show r) placeOrderResult
|
||||
|
||||
@ -188,22 +189,27 @@ runStore mgr config = do
|
||||
|
||||
-- * 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 mgr config = do
|
||||
|
||||
let username = "hsusername"
|
||||
-- createUser
|
||||
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
|
||||
|
||||
-- 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 createUsersWithArrayInputRequest = S.createUsersWithArrayInput (S.User2 users)
|
||||
let createUsersWithArrayInputRequest = S.createUsersWithArrayInput (S.ContentType S.MimeJSON) (S.User2 users)
|
||||
_ <- S.dispatchLbs mgr config createUsersWithArrayInputRequest
|
||||
|
||||
-- createUsersWithArrayInput
|
||||
let createUsersWithListInputRequest = S.createUsersWithListInput (S.User2 users)
|
||||
let createUsersWithListInputRequest = S.createUsersWithListInput (S.ContentType S.MimeJSON) (S.User2 users)
|
||||
_ <- S.dispatchLbs mgr config createUsersWithListInputRequest
|
||||
|
||||
-- getUserByName
|
||||
@ -217,7 +223,7 @@ runUser mgr config = do
|
||||
BCL.putStrLn $ "loginUser: " <> (NH.responseBody loginUserResult)
|
||||
|
||||
-- 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
|
||||
|
||||
-- logoutUser
|
||||
|
@ -1,4 +1,4 @@
|
||||
resolver: lts-10.0
|
||||
resolver: lts-10.10
|
||||
packages:
|
||||
- location: '.'
|
||||
- location: '..'
|
||||
|
@ -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: \" \\
|
||||
|
||||
OpenAPI Version: 3.0.0
|
||||
OpenAPI Version: 3.0.1
|
||||
OpenAPI Petstore API version: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
-}
|
||||
|
@ -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: \" \\
|
||||
|
||||
OpenAPI Version: 3.0.0
|
||||
OpenAPI Version: 3.0.1
|
||||
OpenAPI Petstore API version: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
-}
|
||||
|
@ -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: \" \\
|
||||
|
||||
OpenAPI Version: 3.0.0
|
||||
OpenAPI Version: 3.0.1
|
||||
OpenAPI Petstore API version: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
-}
|
||||
|
@ -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: \" \\
|
||||
|
||||
OpenAPI Version: 3.0.0
|
||||
OpenAPI Version: 3.0.1
|
||||
OpenAPI Petstore API version: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
-}
|
||||
@ -64,19 +64,17 @@ import qualified Prelude as P
|
||||
-- Test serialization of outer boolean types
|
||||
--
|
||||
fakeOuterBooleanSerialize
|
||||
:: (Consumes FakeOuterBooleanSerialize MimeJSON)
|
||||
=> Accept accept -- ^ request accept ('MimeType')
|
||||
-> OpenAPIPetstoreRequest FakeOuterBooleanSerialize MimeJSON Bool accept
|
||||
fakeOuterBooleanSerialize _ =
|
||||
:: (Consumes FakeOuterBooleanSerialize contentType)
|
||||
=> ContentType contentType -- ^ request content-type ('MimeType')
|
||||
-> Accept accept -- ^ request accept ('MimeType')
|
||||
-> OpenAPIPetstoreRequest FakeOuterBooleanSerialize contentType Bool accept
|
||||
fakeOuterBooleanSerialize _ _ =
|
||||
_mkRequest "POST" ["/fake/outer/boolean"]
|
||||
|
||||
data FakeOuterBooleanSerialize
|
||||
|
||||
-- | /Body Param/ "body" - Input boolean as post body
|
||||
instance HasBodyParam FakeOuterBooleanSerialize Body8
|
||||
|
||||
-- | @application/json@
|
||||
instance Consumes FakeOuterBooleanSerialize MimeJSON
|
||||
instance HasBodyParam FakeOuterBooleanSerialize BodyBool
|
||||
|
||||
-- | @*/*@
|
||||
instance MimeType mtype => Produces FakeOuterBooleanSerialize mtype
|
||||
@ -89,10 +87,11 @@ instance MimeType mtype => Produces FakeOuterBooleanSerialize mtype
|
||||
-- Test serialization of object with outer number type
|
||||
--
|
||||
fakeOuterCompositeSerialize
|
||||
:: (Consumes FakeOuterCompositeSerialize MimeJSON)
|
||||
=> Accept accept -- ^ request accept ('MimeType')
|
||||
-> OpenAPIPetstoreRequest FakeOuterCompositeSerialize MimeJSON OuterComposite accept
|
||||
fakeOuterCompositeSerialize _ =
|
||||
:: (Consumes FakeOuterCompositeSerialize contentType)
|
||||
=> ContentType contentType -- ^ request content-type ('MimeType')
|
||||
-> Accept accept -- ^ request accept ('MimeType')
|
||||
-> OpenAPIPetstoreRequest FakeOuterCompositeSerialize contentType OuterComposite accept
|
||||
fakeOuterCompositeSerialize _ _ =
|
||||
_mkRequest "POST" ["/fake/outer/composite"]
|
||||
|
||||
data FakeOuterCompositeSerialize
|
||||
@ -100,9 +99,6 @@ data FakeOuterCompositeSerialize
|
||||
-- | /Body Param/ "OuterComposite" - Input composite as post body
|
||||
instance HasBodyParam FakeOuterCompositeSerialize OuterComposite
|
||||
|
||||
-- | @application/json@
|
||||
instance Consumes FakeOuterCompositeSerialize MimeJSON
|
||||
|
||||
-- | @*/*@
|
||||
instance MimeType mtype => Produces FakeOuterCompositeSerialize mtype
|
||||
|
||||
@ -114,19 +110,17 @@ instance MimeType mtype => Produces FakeOuterCompositeSerialize mtype
|
||||
-- Test serialization of outer number types
|
||||
--
|
||||
fakeOuterNumberSerialize
|
||||
:: (Consumes FakeOuterNumberSerialize MimeJSON)
|
||||
=> Accept accept -- ^ request accept ('MimeType')
|
||||
-> OpenAPIPetstoreRequest FakeOuterNumberSerialize MimeJSON Double accept
|
||||
fakeOuterNumberSerialize _ =
|
||||
:: (Consumes FakeOuterNumberSerialize contentType)
|
||||
=> ContentType contentType -- ^ request content-type ('MimeType')
|
||||
-> Accept accept -- ^ request accept ('MimeType')
|
||||
-> OpenAPIPetstoreRequest FakeOuterNumberSerialize contentType Double accept
|
||||
fakeOuterNumberSerialize _ _ =
|
||||
_mkRequest "POST" ["/fake/outer/number"]
|
||||
|
||||
data FakeOuterNumberSerialize
|
||||
|
||||
-- | /Body Param/ "body" - Input number as post body
|
||||
instance HasBodyParam FakeOuterNumberSerialize Body6
|
||||
|
||||
-- | @application/json@
|
||||
instance Consumes FakeOuterNumberSerialize MimeJSON
|
||||
instance HasBodyParam FakeOuterNumberSerialize Body
|
||||
|
||||
-- | @*/*@
|
||||
instance MimeType mtype => Produces FakeOuterNumberSerialize mtype
|
||||
@ -139,19 +133,17 @@ instance MimeType mtype => Produces FakeOuterNumberSerialize mtype
|
||||
-- Test serialization of outer string types
|
||||
--
|
||||
fakeOuterStringSerialize
|
||||
:: (Consumes FakeOuterStringSerialize MimeJSON)
|
||||
=> Accept accept -- ^ request accept ('MimeType')
|
||||
-> OpenAPIPetstoreRequest FakeOuterStringSerialize MimeJSON Text accept
|
||||
fakeOuterStringSerialize _ =
|
||||
:: (Consumes FakeOuterStringSerialize contentType)
|
||||
=> ContentType contentType -- ^ request content-type ('MimeType')
|
||||
-> Accept accept -- ^ request accept ('MimeType')
|
||||
-> OpenAPIPetstoreRequest FakeOuterStringSerialize contentType Text accept
|
||||
fakeOuterStringSerialize _ _ =
|
||||
_mkRequest "POST" ["/fake/outer/string"]
|
||||
|
||||
data FakeOuterStringSerialize
|
||||
|
||||
-- | /Body Param/ "body" - Input string as post body
|
||||
instance HasBodyParam FakeOuterStringSerialize Body7
|
||||
|
||||
-- | @application/json@
|
||||
instance Consumes FakeOuterStringSerialize MimeJSON
|
||||
instance HasBodyParam FakeOuterStringSerialize BodyText
|
||||
|
||||
-- | @*/*@
|
||||
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)
|
||||
instance HasOptionalParam TestEnumParameters EnumQueryStringArray where
|
||||
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)
|
||||
instance HasOptionalParam TestEnumParameters EnumQueryString where
|
||||
|
@ -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: \" \\
|
||||
|
||||
OpenAPI Version: 3.0.0
|
||||
OpenAPI Version: 3.0.1
|
||||
OpenAPI Petstore API version: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
-}
|
||||
|
@ -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: \" \\
|
||||
|
||||
OpenAPI Version: 3.0.0
|
||||
OpenAPI Version: 3.0.1
|
||||
OpenAPI Petstore API version: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
-}
|
||||
|
@ -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: \" \\
|
||||
|
||||
OpenAPI Version: 3.0.0
|
||||
OpenAPI Version: 3.0.1
|
||||
OpenAPI Petstore API version: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
-}
|
||||
@ -128,11 +128,12 @@ instance Produces GetOrderById MimeJSON
|
||||
-- Place an order for a pet
|
||||
--
|
||||
placeOrder
|
||||
:: (Consumes PlaceOrder MimeJSON, MimeRender MimeJSON Order)
|
||||
=> Accept accept -- ^ request accept ('MimeType')
|
||||
:: (Consumes PlaceOrder contentType, MimeRender contentType Order)
|
||||
=> ContentType contentType -- ^ request content-type ('MimeType')
|
||||
-> Accept accept -- ^ request accept ('MimeType')
|
||||
-> Order -- ^ "order" - order placed for purchasing the pet
|
||||
-> OpenAPIPetstoreRequest PlaceOrder MimeJSON Order accept
|
||||
placeOrder _ order =
|
||||
-> OpenAPIPetstoreRequest PlaceOrder contentType Order accept
|
||||
placeOrder _ _ order =
|
||||
_mkRequest "POST" ["/store/order"]
|
||||
`setBodyParam` order
|
||||
|
||||
@ -141,9 +142,6 @@ data PlaceOrder
|
||||
-- | /Body Param/ "Order" - order placed for purchasing the pet
|
||||
instance HasBodyParam PlaceOrder Order
|
||||
|
||||
-- | @application/json@
|
||||
instance Consumes PlaceOrder MimeJSON
|
||||
|
||||
-- | @application/xml@
|
||||
instance Produces PlaceOrder MimeXML
|
||||
-- | @application/json@
|
||||
|
@ -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: \" \\
|
||||
|
||||
OpenAPI Version: 3.0.0
|
||||
OpenAPI Version: 3.0.1
|
||||
OpenAPI Petstore API version: 1.0.0
|
||||
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.
|
||||
--
|
||||
createUser
|
||||
:: (Consumes CreateUser MimeJSON, MimeRender MimeJSON User)
|
||||
=> User -- ^ "user" - Created user object
|
||||
-> OpenAPIPetstoreRequest CreateUser MimeJSON NoContent MimeNoContent
|
||||
createUser user =
|
||||
:: (Consumes CreateUser contentType, MimeRender contentType User)
|
||||
=> ContentType contentType -- ^ request content-type ('MimeType')
|
||||
-> User -- ^ "user" - Created user object
|
||||
-> OpenAPIPetstoreRequest CreateUser contentType NoContent MimeNoContent
|
||||
createUser _ user =
|
||||
_mkRequest "POST" ["/user"]
|
||||
`setBodyParam` user
|
||||
|
||||
@ -78,9 +79,6 @@ data CreateUser
|
||||
-- | /Body Param/ "User" - Created user object
|
||||
instance HasBodyParam CreateUser User
|
||||
|
||||
-- | @application/json@
|
||||
instance Consumes CreateUser MimeJSON
|
||||
|
||||
instance Produces CreateUser MimeNoContent
|
||||
|
||||
|
||||
@ -91,10 +89,11 @@ instance Produces CreateUser MimeNoContent
|
||||
-- Creates list of users with given input array
|
||||
--
|
||||
createUsersWithArrayInput
|
||||
:: (Consumes CreateUsersWithArrayInput MimeJSON, MimeRender MimeJSON User2)
|
||||
=> User2 -- ^ "user" - List of user object
|
||||
-> OpenAPIPetstoreRequest CreateUsersWithArrayInput MimeJSON NoContent MimeNoContent
|
||||
createUsersWithArrayInput user =
|
||||
:: (Consumes CreateUsersWithArrayInput contentType, MimeRender contentType User2)
|
||||
=> ContentType contentType -- ^ request content-type ('MimeType')
|
||||
-> User2 -- ^ "user" - List of user object
|
||||
-> OpenAPIPetstoreRequest CreateUsersWithArrayInput contentType NoContent MimeNoContent
|
||||
createUsersWithArrayInput _ user =
|
||||
_mkRequest "POST" ["/user/createWithArray"]
|
||||
`setBodyParam` user
|
||||
|
||||
@ -103,9 +102,6 @@ data CreateUsersWithArrayInput
|
||||
-- | /Body Param/ "User" - List of user object
|
||||
instance HasBodyParam CreateUsersWithArrayInput User2
|
||||
|
||||
-- | @application/json@
|
||||
instance Consumes CreateUsersWithArrayInput MimeJSON
|
||||
|
||||
instance Produces CreateUsersWithArrayInput MimeNoContent
|
||||
|
||||
|
||||
@ -116,10 +112,11 @@ instance Produces CreateUsersWithArrayInput MimeNoContent
|
||||
-- Creates list of users with given input array
|
||||
--
|
||||
createUsersWithListInput
|
||||
:: (Consumes CreateUsersWithListInput MimeJSON, MimeRender MimeJSON User2)
|
||||
=> User2 -- ^ "user" - List of user object
|
||||
-> OpenAPIPetstoreRequest CreateUsersWithListInput MimeJSON NoContent MimeNoContent
|
||||
createUsersWithListInput user =
|
||||
:: (Consumes CreateUsersWithListInput contentType, MimeRender contentType User2)
|
||||
=> ContentType contentType -- ^ request content-type ('MimeType')
|
||||
-> User2 -- ^ "user" - List of user object
|
||||
-> OpenAPIPetstoreRequest CreateUsersWithListInput contentType NoContent MimeNoContent
|
||||
createUsersWithListInput _ user =
|
||||
_mkRequest "POST" ["/user/createWithList"]
|
||||
`setBodyParam` user
|
||||
|
||||
@ -128,9 +125,6 @@ data CreateUsersWithListInput
|
||||
-- | /Body Param/ "User" - List of user object
|
||||
instance HasBodyParam CreateUsersWithListInput User2
|
||||
|
||||
-- | @application/json@
|
||||
instance Consumes CreateUsersWithListInput MimeJSON
|
||||
|
||||
instance Produces CreateUsersWithListInput MimeNoContent
|
||||
|
||||
|
||||
@ -223,11 +217,12 @@ instance Produces LogoutUser MimeNoContent
|
||||
-- This can only be done by the logged in user.
|
||||
--
|
||||
updateUser
|
||||
:: (Consumes UpdateUser MimeJSON, MimeRender MimeJSON User)
|
||||
=> User -- ^ "user" - Updated user object
|
||||
:: (Consumes UpdateUser contentType, MimeRender contentType User)
|
||||
=> ContentType contentType -- ^ request content-type ('MimeType')
|
||||
-> User -- ^ "user" - Updated user object
|
||||
-> Username -- ^ "username" - name that need to be deleted
|
||||
-> OpenAPIPetstoreRequest UpdateUser MimeJSON NoContent MimeNoContent
|
||||
updateUser user (Username username) =
|
||||
-> OpenAPIPetstoreRequest UpdateUser contentType NoContent MimeNoContent
|
||||
updateUser _ user (Username username) =
|
||||
_mkRequest "PUT" ["/user/",toPath username]
|
||||
`setBodyParam` user
|
||||
|
||||
@ -236,8 +231,5 @@ data UpdateUser
|
||||
-- | /Body Param/ "User" - Updated user object
|
||||
instance HasBodyParam UpdateUser User
|
||||
|
||||
-- | @application/json@
|
||||
instance Consumes UpdateUser MimeJSON
|
||||
|
||||
instance Produces UpdateUser MimeNoContent
|
||||
|
||||
|
@ -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: \" \\
|
||||
|
||||
OpenAPI Version: 3.0.0
|
||||
OpenAPI Version: 3.0.1
|
||||
OpenAPI Petstore API version: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
-}
|
||||
|
@ -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: \" \\
|
||||
|
||||
OpenAPI Version: 3.0.0
|
||||
OpenAPI Version: 3.0.1
|
||||
OpenAPI Petstore API version: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
-}
|
||||
|
@ -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: \" \\
|
||||
|
||||
OpenAPI Version: 3.0.0
|
||||
OpenAPI Version: 3.0.1
|
||||
OpenAPI Petstore API version: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
-}
|
||||
|
@ -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: \" \\
|
||||
|
||||
OpenAPI Version: 3.0.0
|
||||
OpenAPI Version: 3.0.1
|
||||
OpenAPI Petstore API version: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
-}
|
||||
|
@ -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: \" \\
|
||||
|
||||
OpenAPI Version: 3.0.0
|
||||
OpenAPI Version: 3.0.1
|
||||
OpenAPI Petstore API version: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
-}
|
||||
@ -72,14 +72,14 @@ newtype AdditionalMetadata = AdditionalMetadata { unAdditionalMetadata :: Text }
|
||||
-- ** ApiKey
|
||||
newtype ApiKey = ApiKey { unApiKey :: Text } deriving (P.Eq, P.Show)
|
||||
|
||||
-- ** Body6
|
||||
newtype Body6 = Body6 { unBody6 :: Double } deriving (P.Eq, P.Show, A.ToJSON)
|
||||
-- ** Body
|
||||
newtype Body = Body { unBody :: Double } deriving (P.Eq, P.Show, A.ToJSON)
|
||||
|
||||
-- ** Body7
|
||||
newtype Body7 = Body7 { unBody7 :: Text } deriving (P.Eq, P.Show, A.ToJSON)
|
||||
-- ** BodyBool
|
||||
newtype BodyBool = BodyBool { unBodyBool :: Bool } deriving (P.Eq, P.Show, A.ToJSON)
|
||||
|
||||
-- ** Body8
|
||||
newtype Body8 = Body8 { unBody8 :: Bool } deriving (P.Eq, P.Show, A.ToJSON)
|
||||
-- ** BodyText
|
||||
newtype BodyText = BodyText { unBodyText :: Text } deriving (P.Eq, P.Show, A.ToJSON)
|
||||
|
||||
-- ** Byte
|
||||
newtype Byte = Byte { unByte :: ByteArray } deriving (P.Eq, P.Show)
|
||||
@ -416,253 +416,6 @@ mkArrayTest =
|
||||
, 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
|
||||
data Capitalization = Capitalization
|
||||
|
@ -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: \" \\
|
||||
|
||||
OpenAPI Version: 3.0.0
|
||||
OpenAPI Version: 3.0.1
|
||||
OpenAPI Petstore API version: 1.0.0
|
||||
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
|
||||
|
||||
-- | 'capitalizationSmallCamel' Lens
|
||||
|
@ -10,7 +10,7 @@ description: .
|
||||
.
|
||||
OpenAPI Petstore API version: 1.0.0
|
||||
.
|
||||
OpenAPI version: 3.0.0
|
||||
OpenAPI version: 3.0.1
|
||||
.
|
||||
category: Web
|
||||
homepage: https://openapi-generator.tech
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -164,6 +164,7 @@ testPetOps mgr config =
|
||||
|
||||
-- * STORE TESTS
|
||||
|
||||
instance S.Consumes S.PlaceOrder S.MimeJSON
|
||||
|
||||
testStoreOps :: NH.Manager -> S.OpenAPIPetstoreConfig -> Spec
|
||||
testStoreOps mgr config = do
|
||||
@ -183,7 +184,7 @@ testStoreOps mgr config = do
|
||||
|
||||
it "placeOrder" $ do
|
||||
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.orderId = Just 21
|
||||
, S.orderQuantity = Just 210
|
||||
@ -221,6 +222,11 @@ testStoreOps mgr config = do
|
||||
|
||||
-- * 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 mgr config = do
|
||||
|
||||
@ -245,19 +251,19 @@ testUserOps mgr config = do
|
||||
|
||||
before (pure _user) $
|
||||
it "createUser" $ \user -> do
|
||||
let createUserRequest = S.createUser user
|
||||
let createUserRequest = S.createUser (S.ContentType S.MimeJSON) user
|
||||
createUserResult <- S.dispatchLbs mgr config createUserRequest
|
||||
NH.responseStatus createUserResult `shouldBe` NH.status200
|
||||
|
||||
before (pure _users) $
|
||||
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
|
||||
NH.responseStatus createUsersWithArrayInputResult `shouldBe` NH.status200
|
||||
|
||||
before (pure _users) $
|
||||
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
|
||||
NH.responseStatus createUsersWithListInputResult `shouldBe` NH.status200
|
||||
|
||||
@ -278,7 +284,7 @@ testUserOps mgr config = do
|
||||
|
||||
before (pure (_username, _user)) $
|
||||
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
|
||||
NH.responseStatus updateUserResult `shouldBe` NH.status200
|
||||
|
||||
|
@ -130,54 +130,6 @@ instance Arbitrary ArrayTest where
|
||||
<*> arbitrary -- arrayTestArrayArrayOfInteger :: Maybe [[Integer]]
|
||||
<*> 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
|
||||
arbitrary =
|
||||
Capitalization
|
||||
|
@ -27,12 +27,6 @@ main =
|
||||
propMimeEq MimeJSON (Proxy :: Proxy ArrayOfArrayOfNumberOnly)
|
||||
propMimeEq MimeJSON (Proxy :: Proxy ArrayOfNumberOnly)
|
||||
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 Cat)
|
||||
propMimeEq MimeJSON (Proxy :: Proxy Category)
|
||||
|
@ -1 +1 @@
|
||||
3.0.0-SNAPSHOT
|
||||
3.3.0-SNAPSHOT
|
Loading…
x
Reference in New Issue
Block a user