diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java
index 3a90ef15460..d6eddb057fa 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java
@@ -3856,6 +3856,11 @@ public class DefaultCodegen implements CodegenConfig {
// input name and age => input_name_and_age
name = name.replaceAll(" ", "_");
+ // /api/films/get => _api_films_get
+ // \api\films\get => _api_films_get
+ name = name.replaceAll("/", "_");
+ name = name.replaceAll("\\\\", "_");
+
// remove everything else other than word, number and _
// $php_variable => php_variable
if (allowUnicodeIdentifiers) { //could be converted to a single line with ?: operator
diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Fake.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Fake.hs
index 78f572d069e..9e8a52b2522 100644
--- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Fake.hs
+++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Fake.hs
@@ -82,11 +82,11 @@ instance HasBodyParam CreateXmlItem XmlItem
-- | @application/xml@
instance Consumes CreateXmlItem MimeXML
-- | @text/xml@
-instance Consumes CreateXmlItem MimeTextxml
+instance Consumes CreateXmlItem MimeTextXml
-- | @text/xml; charset=utf-8@
-instance Consumes CreateXmlItem MimeTextxmlCharsetutf8
+instance Consumes CreateXmlItem MimeTextXmlCharsetutf8
-- | @text/xml; charset=utf-16@
-instance Consumes CreateXmlItem MimeTextxmlCharsetutf16
+instance Consumes CreateXmlItem MimeTextXmlCharsetutf16
-- | @application/xml; charset=utf-8@
instance Consumes CreateXmlItem MimeXmlCharsetutf8
-- | @application/xml; charset=utf-16@
diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/MimeTypes.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/MimeTypes.hs
index ee02f76b03b..09a22f66398 100644
--- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/MimeTypes.hs
+++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/MimeTypes.hs
@@ -223,33 +223,33 @@ instance MimeType MimeXmlCharsetutf8 where
-- instance MimeRender MimeXmlCharsetutf8 T.Text where mimeRender _ = undefined
-- instance MimeUnrender MimeXmlCharsetutf8 T.Text where mimeUnrender _ = undefined
--- ** MimeTextxml
+-- ** MimeTextXml
-data MimeTextxml = MimeTextxml deriving (P.Typeable)
+data MimeTextXml = MimeTextXml deriving (P.Typeable)
-- | @text/xml@
-instance MimeType MimeTextxml where
+instance MimeType MimeTextXml where
mimeType _ = Just $ P.fromString "text/xml"
--- instance MimeRender MimeTextxml T.Text where mimeRender _ = undefined
--- instance MimeUnrender MimeTextxml T.Text where mimeUnrender _ = undefined
+-- instance MimeRender MimeTextXml T.Text where mimeRender _ = undefined
+-- instance MimeUnrender MimeTextXml T.Text where mimeUnrender _ = undefined
--- ** MimeTextxmlCharsetutf16
+-- ** MimeTextXmlCharsetutf16
-data MimeTextxmlCharsetutf16 = MimeTextxmlCharsetutf16 deriving (P.Typeable)
+data MimeTextXmlCharsetutf16 = MimeTextXmlCharsetutf16 deriving (P.Typeable)
-- | @text/xml; charset=utf-16@
-instance MimeType MimeTextxmlCharsetutf16 where
+instance MimeType MimeTextXmlCharsetutf16 where
mimeType _ = Just $ P.fromString "text/xml; charset=utf-16"
--- instance MimeRender MimeTextxmlCharsetutf16 T.Text where mimeRender _ = undefined
--- instance MimeUnrender MimeTextxmlCharsetutf16 T.Text where mimeUnrender _ = undefined
+-- instance MimeRender MimeTextXmlCharsetutf16 T.Text where mimeRender _ = undefined
+-- instance MimeUnrender MimeTextXmlCharsetutf16 T.Text where mimeUnrender _ = undefined
--- ** MimeTextxmlCharsetutf8
+-- ** MimeTextXmlCharsetutf8
-data MimeTextxmlCharsetutf8 = MimeTextxmlCharsetutf8 deriving (P.Typeable)
+data MimeTextXmlCharsetutf8 = MimeTextXmlCharsetutf8 deriving (P.Typeable)
-- | @text/xml; charset=utf-8@
-instance MimeType MimeTextxmlCharsetutf8 where
+instance MimeType MimeTextXmlCharsetutf8 where
mimeType _ = Just $ P.fromString "text/xml; charset=utf-8"
--- instance MimeRender MimeTextxmlCharsetutf8 T.Text where mimeRender _ = undefined
--- instance MimeUnrender MimeTextxmlCharsetutf8 T.Text where mimeUnrender _ = undefined
+-- instance MimeRender MimeTextXmlCharsetutf8 T.Text where mimeRender _ = undefined
+-- instance MimeUnrender MimeTextXmlCharsetutf8 T.Text where mimeUnrender _ = undefined
diff --git a/samples/client/petstore/javascript-es6/package.json b/samples/client/petstore/javascript-es6/package.json
index ae6e93fe8dc..c89469d525c 100644
--- a/samples/client/petstore/javascript-es6/package.json
+++ b/samples/client/petstore/javascript-es6/package.json
@@ -1,7 +1,7 @@
{
"name": "open_api_petstore",
"version": "1.0.0",
- "description": "This_spec_is_mainly_for_testing_Petstore_server_and_contains_fake_endpoints_models__Please_do_not_use_this_for_any_other_purpose__Special_characters__",
+ "description": "This_spec_is_mainly_for_testing_Petstore_server_and_contains_fake_endpoints_models__Please_do_not_use_this_for_any_other_purpose__Special_characters___",
"license": "Apache-2.0",
"main": "dist/index.js",
"scripts": {
diff --git a/samples/client/petstore/javascript-es6/src/index.js b/samples/client/petstore/javascript-es6/src/index.js
index 51e8d4b9f81..e4e2a2fb113 100644
--- a/samples/client/petstore/javascript-es6/src/index.js
+++ b/samples/client/petstore/javascript-es6/src/index.js
@@ -66,7 +66,7 @@ import UserApi from './api/UserApi';
/**
-* 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___.
* The index
module provides access to constructors for all the classes which comprise the public API.
*
* An AMD (recommended!) or CommonJS application will generally do something equivalent to the following:
diff --git a/samples/client/petstore/javascript-promise-es6/package.json b/samples/client/petstore/javascript-promise-es6/package.json
index ae6e93fe8dc..c89469d525c 100644
--- a/samples/client/petstore/javascript-promise-es6/package.json
+++ b/samples/client/petstore/javascript-promise-es6/package.json
@@ -1,7 +1,7 @@
{
"name": "open_api_petstore",
"version": "1.0.0",
- "description": "This_spec_is_mainly_for_testing_Petstore_server_and_contains_fake_endpoints_models__Please_do_not_use_this_for_any_other_purpose__Special_characters__",
+ "description": "This_spec_is_mainly_for_testing_Petstore_server_and_contains_fake_endpoints_models__Please_do_not_use_this_for_any_other_purpose__Special_characters___",
"license": "Apache-2.0",
"main": "dist/index.js",
"scripts": {
diff --git a/samples/client/petstore/javascript-promise-es6/src/index.js b/samples/client/petstore/javascript-promise-es6/src/index.js
index 51e8d4b9f81..e4e2a2fb113 100644
--- a/samples/client/petstore/javascript-promise-es6/src/index.js
+++ b/samples/client/petstore/javascript-promise-es6/src/index.js
@@ -66,7 +66,7 @@ import UserApi from './api/UserApi';
/**
-* 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___.
* The index
module provides access to constructors for all the classes which comprise the public API.
*
* An AMD (recommended!) or CommonJS application will generally do something equivalent to the following:
diff --git a/samples/client/petstore/javascript-promise/package.json b/samples/client/petstore/javascript-promise/package.json
index 9c4bc8eedd0..86b2083c680 100644
--- a/samples/client/petstore/javascript-promise/package.json
+++ b/samples/client/petstore/javascript-promise/package.json
@@ -1,7 +1,7 @@
{
"name": "open_api_petstore",
"version": "1.0.0",
- "description": "This_spec_is_mainly_for_testing_Petstore_server_and_contains_fake_endpoints_models__Please_do_not_use_this_for_any_other_purpose__Special_characters__",
+ "description": "This_spec_is_mainly_for_testing_Petstore_server_and_contains_fake_endpoints_models__Please_do_not_use_this_for_any_other_purpose__Special_characters___",
"license": "Apache-2.0",
"main": "src/index.js",
"scripts": {
diff --git a/samples/client/petstore/javascript-promise/src/index.js b/samples/client/petstore/javascript-promise/src/index.js
index 85a6c371d79..b7f8ca6bbf8 100644
--- a/samples/client/petstore/javascript-promise/src/index.js
+++ b/samples/client/petstore/javascript-promise/src/index.js
@@ -25,7 +25,7 @@
'use strict';
/**
- * 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___.
* The index
module provides access to constructors for all the classes which comprise the public API.
*
* An AMD (recommended!) or CommonJS application will generally do something equivalent to the following:
diff --git a/samples/client/petstore/javascript/package.json b/samples/client/petstore/javascript/package.json
index 9c4bc8eedd0..86b2083c680 100644
--- a/samples/client/petstore/javascript/package.json
+++ b/samples/client/petstore/javascript/package.json
@@ -1,7 +1,7 @@
{
"name": "open_api_petstore",
"version": "1.0.0",
- "description": "This_spec_is_mainly_for_testing_Petstore_server_and_contains_fake_endpoints_models__Please_do_not_use_this_for_any_other_purpose__Special_characters__",
+ "description": "This_spec_is_mainly_for_testing_Petstore_server_and_contains_fake_endpoints_models__Please_do_not_use_this_for_any_other_purpose__Special_characters___",
"license": "Apache-2.0",
"main": "src/index.js",
"scripts": {
diff --git a/samples/client/petstore/javascript/src/index.js b/samples/client/petstore/javascript/src/index.js
index 85a6c371d79..b7f8ca6bbf8 100644
--- a/samples/client/petstore/javascript/src/index.js
+++ b/samples/client/petstore/javascript/src/index.js
@@ -25,7 +25,7 @@
'use strict';
/**
- * 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___.
* The index
module provides access to constructors for all the classes which comprise the public API.
*
* An AMD (recommended!) or CommonJS application will generally do something equivalent to the following: