diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/StaticHtml2Generator.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/StaticHtml2Generator.java index 541044f03db..37fda7e0b9b 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/StaticHtml2Generator.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/StaticHtml2Generator.java @@ -17,12 +17,14 @@ package org.openapitools.codegen.languages; +import io.swagger.v3.core.util.Json; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.Operation; import io.swagger.v3.oas.models.info.Info; import io.swagger.v3.oas.models.media.ArraySchema; import io.swagger.v3.oas.models.media.Schema; +import com.fasterxml.jackson.databind.JsonNode; import org.apache.commons.lang3.StringUtils; import org.openapitools.codegen.CliOption; import org.openapitools.codegen.CodegenConfig; @@ -175,6 +177,22 @@ public class StaticHtml2Generator extends DefaultCodegen implements CodegenConfi additionalProperties.put("jsModuleName", jsModuleName); preparHtmlForGlobalDescription(openAPI); + + Map vendorExtensions = openAPI.getExtensions(); + if (vendorExtensions != null) { + for(Map.Entry vendorExtension: vendorExtensions.entrySet()) { + // Vendor extensions could be Maps (objects). If we wanted to iterate through them in our template files + // without knowing the keys beforehand, the default `toString` method renders them unusable. Instead, we + // convert them to JSON strings now, which means we can easily use them later. + if (vendorExtension.getValue() instanceof Map) { + this.vendorExtensions().put(vendorExtension.getKey(), Json.mapper().convertValue(vendorExtension.getValue(), JsonNode.class)); + } else { + this.vendorExtensions().put(vendorExtension.getKey(), vendorExtension.getValue()); + } + } + } + openAPI.setExtensions(this.vendorExtensions); + } @Override diff --git a/modules/openapi-generator/src/main/resources/htmlDocs2/fonts.mustache b/modules/openapi-generator/src/main/resources/htmlDocs2/fonts.mustache new file mode 100644 index 00000000000..957dd2145f8 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/htmlDocs2/fonts.mustache @@ -0,0 +1 @@ +@import url('https://fonts.googleapis.com/css?family=Source+Code+Pro'); \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/htmlDocs2/index.mustache b/modules/openapi-generator/src/main/resources/htmlDocs2/index.mustache index 6ce9aa2e34c..577ab978d2b 100644 --- a/modules/openapi-generator/src/main/resources/htmlDocs2/index.mustache +++ b/modules/openapi-generator/src/main/resources/htmlDocs2/index.mustache @@ -103,20 +103,31 @@ });
@@ -162,7 +173,9 @@
Version: {{{version}}}
{{/version}}
-
{{{appDescription}}}
+
+ {{{appDescription}}} +
@@ -200,6 +213,7 @@
  • PHP
  • Perl
  • Python
  • +
  • Rust
  • @@ -243,8 +257,22 @@
    {{>sample_python}}
    + +
    +
    {{>sample_rust}}
    +
    +

    Scopes

    + + {{#authMethods}}{{#scopes}} + + + + + {{/scopes}}{{/authMethods}} +
    {{scope}}{{description}}
    +

    Parameters

    {{#hasPathParams}} @@ -314,31 +342,77 @@

    Responses

    {{#responses}} -

    Status: {{code}} - {{message}}

    +

    +

    + -
    @@ -1188,8 +1313,37 @@ try: except ApiException as e: print("Exception when calling PetApi->addPet: %s\n" % e)
    + +
    +
    extern crate PetApi;
    +
    +pub fn main() {
    +    let pet = ; // Pet
    +
    +    let mut context = PetApi::Context::default();
    +    let result = client.addPet(pet, &context).wait();
    +    println!("{:?}", result);
    +
    +}
    +
    +
    +

    Scopes

    + + + + + + + + + + + + +
    write:petsmodify pets in your account
    read:petsread your pets
    +

    Parameters

    @@ -1202,8 +1356,7 @@ except ApiException as e: pet * - - +

    Pet object that needs to be added to the store

    + + +
    @@ -1476,8 +1644,38 @@ try: except ApiException as e: print("Exception when calling PetApi->deletePet: %s\n" % e)
    + +
    +
    extern crate PetApi;
    +
    +pub fn main() {
    +    let petId = 789; // Long
    +    let apiKey = apiKey_example; // String
    +
    +    let mut context = PetApi::Context::default();
    +    let result = client.deletePet(petId, apiKey, &context).wait();
    +    println!("{:?}", result);
    +
    +}
    +
    +
    +

    Scopes

    + + + + + + + + + + + + +
    write:petsmodify pets in your account
    read:petsread your pets
    +

    Parameters

    Path parameters
    @@ -1500,8 +1698,8 @@ except ApiException as e: (int64) -
    - Pet id to delete +
    +Pet id to delete
    @@ -1543,14 +1741,28 @@ except ApiException as e:

    Responses

    -

    Status: 400 - Invalid pet value

    +

    +

    + + + +

    @@ -1582,6 +1794,7 @@ except ApiException as e:
  • PHP
  • Perl
  • Python
  • +
  • Rust
  • @@ -1785,8 +1998,37 @@ try: except ApiException as e: print("Exception when calling PetApi->findPetsByStatus: %s\n" % e)
    + +
    +
    extern crate PetApi;
    +
    +pub fn main() {
    +    let status = ; // array[String]
    +
    +    let mut context = PetApi::Context::default();
    +    let result = client.findPetsByStatus(status, &context).wait();
    +    println!("{:?}", result);
    +
    +}
    +
    +
    +

    Scopes

    + + + + + + + + + + + + +
    write:petsmodify pets in your account
    read:petsread your pets
    +

    Parameters

    @@ -1810,8 +2052,8 @@ except ApiException as e: array[String] -
    - Status values that need to be considered for filter +
    +Status values that need to be considered for filter
    @@ -1825,18 +2067,34 @@ except ApiException as e:

    Responses

    -

    Status: 200 - successful operation

    +

    +

    + -
    @@ -2125,8 +2396,37 @@ try: except ApiException as e: print("Exception when calling PetApi->findPetsByTags: %s\n" % e)
    + +
    +
    extern crate PetApi;
    +
    +pub fn main() {
    +    let tags = ; // array[String]
    +
    +    let mut context = PetApi::Context::default();
    +    let result = client.findPetsByTags(tags, &context).wait();
    +    println!("{:?}", result);
    +
    +}
    +
    +
    +

    Scopes

    + + + + + + + + + + + + +
    write:petsmodify pets in your account
    read:petsread your pets
    +

    Parameters

    @@ -2150,8 +2450,8 @@ except ApiException as e: array[String] -
    - Tags to filter by +
    +Tags to filter by
    @@ -2165,18 +2465,34 @@ except ApiException as e:

    Responses

    -

    Status: 200 - successful operation

    +

    +

    + -
    @@ -2479,8 +2808,27 @@ try: except ApiException as e: print("Exception when calling PetApi->getPetById: %s\n" % e)
    + +
    +
    extern crate PetApi;
    +
    +pub fn main() {
    +    let petId = 789; // Long
    +
    +    let mut context = PetApi::Context::default();
    +    let result = client.getPetById(petId, &context).wait();
    +    println!("{:?}", result);
    +
    +}
    +
    +
    +

    Scopes

    + + +
    +

    Parameters

    Path parameters
    @@ -2503,8 +2851,8 @@ except ApiException as e: (int64) -
    - ID of pet to return +
    +ID of pet to return
    @@ -2522,18 +2870,34 @@ except ApiException as e:

    Responses

    -

    Status: 200 - successful operation

    +

    +

    + -
    @@ -3480,8 +3988,39 @@ try: except ApiException as e: print("Exception when calling PetApi->uploadFile: %s\n" % e)
    + +
    +
    extern crate PetApi;
    +
    +pub fn main() {
    +    let petId = 789; // Long
    +    let additionalMetadata = additionalMetadata_example; // String
    +    let file = BINARY_DATA_HERE; // File
    +
    +    let mut context = PetApi::Context::default();
    +    let result = client.uploadFile(petId, additionalMetadata, file, &context).wait();
    +    println!("{:?}", result);
    +
    +}
    +
    +
    +

    Scopes

    + + + + + + + + + + + + +
    write:petsmodify pets in your account
    read:petsread your pets
    +

    Parameters

    Path parameters
    @@ -3504,8 +4043,8 @@ except ApiException as e: (int64) -
    - ID of pet to update +
    +ID of pet to update
    @@ -3537,8 +4076,8 @@ except ApiException as e: String -
    - Additional data to pass to server +
    +Additional data to pass to server
    @@ -3560,8 +4099,8 @@ except ApiException as e: (binary) -
    - file to upload +
    +file to upload
    @@ -3573,18 +4112,34 @@ except ApiException as e:

    Responses

    -

    Status: 200 - successful operation

    +

    +

    + -
    @@ -3821,8 +4375,27 @@ try: except ApiException as e: print("Exception when calling StoreApi->deleteOrder: %s\n" % e)
    + +
    +
    extern crate StoreApi;
    +
    +pub fn main() {
    +    let orderId = orderId_example; // String
    +
    +    let mut context = StoreApi::Context::default();
    +    let result = client.deleteOrder(orderId, &context).wait();
    +    println!("{:?}", result);
    +
    +}
    +
    +
    +

    Scopes

    + + +
    +

    Parameters

    Path parameters
    @@ -3842,8 +4415,8 @@ except ApiException as e: String -
    - ID of the order that needs to be deleted +
    +ID of the order that needs to be deleted
    @@ -3861,22 +4434,50 @@ except ApiException as e:

    Responses

    -

    Status: 400 - Invalid ID supplied

    +

    +

    + + + +
    @@ -4116,8 +4718,26 @@ try: except ApiException as e: print("Exception when calling StoreApi->getInventory: %s\n" % e)
    + +
    +
    extern crate StoreApi;
    +
    +pub fn main() {
    +
    +    let mut context = StoreApi::Context::default();
    +    let result = client.getInventory(&context).wait();
    +    println!("{:?}", result);
    +
    +}
    +
    +
    +

    Scopes

    + + +
    +

    Parameters

    @@ -4126,18 +4746,34 @@ except ApiException as e:

    Responses

    -

    Status: 200 - successful operation

    +

    +

    + -
    @@ -4384,8 +5019,27 @@ try: except ApiException as e: print("Exception when calling StoreApi->getOrderById: %s\n" % e)
    + +
    +
    extern crate StoreApi;
    +
    +pub fn main() {
    +    let orderId = 789; // Long
    +
    +    let mut context = StoreApi::Context::default();
    +    let result = client.getOrderById(orderId, &context).wait();
    +    println!("{:?}", result);
    +
    +}
    +
    +
    +

    Scopes

    + + +
    +

    Parameters

    Path parameters
    @@ -4408,8 +5062,8 @@ except ApiException as e: (int64) -
    - ID of pet that needs to be fetched +
    +ID of pet that needs to be fetched
    @@ -4427,18 +5081,34 @@ except ApiException as e:

    Responses

    -

    Status: 200 - successful operation

    +

    +

    + -
    @@ -5257,8 +6034,27 @@ try: except ApiException as e: print("Exception when calling UserApi->createUsersWithArrayInput: %s\n" % e)
    + +
    +
    extern crate UserApi;
    +
    +pub fn main() {
    +    let user = ; // array[User]
    +
    +    let mut context = UserApi::Context::default();
    +    let result = client.createUsersWithArrayInput(user, &context).wait();
    +    println!("{:?}", result);
    +
    +}
    +
    +
    +

    Scopes

    + + +
    +

    Parameters

    @@ -5271,8 +6067,7 @@ except ApiException as e: user * - - +

    List of user object

    + + +
    @@ -5507,8 +6317,27 @@ try: except ApiException as e: print("Exception when calling UserApi->createUsersWithListInput: %s\n" % e)
    + +
    +
    extern crate UserApi;
    +
    +pub fn main() {
    +    let user = ; // array[User]
    +
    +    let mut context = UserApi::Context::default();
    +    let result = client.createUsersWithListInput(user, &context).wait();
    +    println!("{:?}", result);
    +
    +}
    +
    +
    +

    Scopes

    + + +
    +

    Parameters

    @@ -5521,8 +6350,7 @@ except ApiException as e: user * - - +

    List of user object

    + + +
    @@ -5757,8 +6600,27 @@ try: except ApiException as e: print("Exception when calling UserApi->deleteUser: %s\n" % e)
    + +
    +
    extern crate UserApi;
    +
    +pub fn main() {
    +    let username = username_example; // String
    +
    +    let mut context = UserApi::Context::default();
    +    let result = client.deleteUser(username, &context).wait();
    +    println!("{:?}", result);
    +
    +}
    +
    +
    +

    Scopes

    + + +
    +

    Parameters

    Path parameters
    @@ -5778,8 +6640,8 @@ except ApiException as e: String -
    - The name that needs to be deleted +
    +The name that needs to be deleted
    @@ -5797,22 +6659,50 @@ except ApiException as e:

    Responses

    -

    Status: 400 - Invalid username supplied

    +

    +

    + + + +
    @@ -6020,8 +6911,27 @@ try: except ApiException as e: print("Exception when calling UserApi->getUserByName: %s\n" % e)
    + +
    +
    extern crate UserApi;
    +
    +pub fn main() {
    +    let username = username_example; // String
    +
    +    let mut context = UserApi::Context::default();
    +    let result = client.getUserByName(username, &context).wait();
    +    println!("{:?}", result);
    +
    +}
    +
    +
    +

    Scopes

    + + +
    +

    Parameters

    Path parameters
    @@ -6041,8 +6951,8 @@ except ApiException as e: String -
    - The name that needs to be fetched. Use user1 for testing. +
    +The name that needs to be fetched. Use user1 for testing.
    @@ -6060,18 +6970,34 @@ except ApiException as e:

    Responses

    -

    Status: 200 - successful operation

    +

    +

    + -
    @@ -6922,8 +7957,28 @@ try: except ApiException as e: print("Exception when calling UserApi->updateUser: %s\n" % e)
    + +
    +
    extern crate UserApi;
    +
    +pub fn main() {
    +    let username = username_example; // String
    +    let user = ; // User
    +
    +    let mut context = UserApi::Context::default();
    +    let result = client.updateUser(username, user, &context).wait();
    +    println!("{:?}", result);
    +
    +}
    +
    +
    +

    Scopes

    + + +
    +

    Parameters

    Path parameters
    @@ -6943,8 +7998,8 @@ except ApiException as e: String -
    - name that need to be deleted +
    +name that need to be deleted
    @@ -6966,8 +8021,7 @@ except ApiException as e: user * - - +

    Updated user object

    + + +