Skip to content

[kotlin] api/model docs#5731

Merged
wing328 merged 1 commit intoswagger-api:masterfrom
jimschubert:kotlin-api-model-docs
May 30, 2017
Merged

[kotlin] api/model docs#5731
wing328 merged 1 commit intoswagger-api:masterfrom
jimschubert:kotlin-api-model-docs

Conversation

@jimschubert
Copy link
Copy Markdown
Contributor

PR checklist

  • Read the contribution guidelines.
  • Ran the shell/batch script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh and ./bin/security/{LANG}-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates)
  • Filed the PR against the correct branch: master for non-breaking changes and 2.3.0 branch for breaking (non-backward compatible) changes.

Description of the PR

This commit adds Api/Model/Auth documentation to the generated
README.md. Because auth support is not yet fully implemented (users can
manually set default headers globally), there aren't examples for helper
auth methods.

Models with inline enums document allowed values rather than pointing to
a generated enum class.

Two global additionalProperties were added (generateApiDocs,
generateModelDocs) to allow templates to conditionally display
documentation depending on these mutually exclusive settings. All
current generators supporting docs will attempt to link to generated
models when only api docs are specified.

This also moves the $@ bash parameter in bin/kotlin-client-petstore.sh
to the end of the args variable. This is because $@ can only be used to
pass System properties like -DdebugModels, can can already be passed as:

JAVA_OPTS="$JAVA_OPTS -DdebugModels" ./bin/kotlin-client-petstore.sh

By moving the $@ to the end of the args, it allows us to pass additional
properties and other switches directly to the script.

NOTE I didn't regenerate samples because I've moved the kotlin output from samples/client/kotlin to samples/client/petstore/kotlin as part of PR #5729. I wanted to avoid too many merge conflicts and figured docs would get generated eventually anyway. Here are some samples:


Pet

Properties

Name Type Description Notes
id kotlin.Long [optional]
category Category [optional]
name kotlin.String
photoUrls kotlin.Array<kotlin.String>
tags kotlin.Array<Tag> [optional]
status inline pet status in the store [optional]

Enum: status

Name Value
status available, pending, sold

StoreApi

All URIs are relative to http://petstore.swagger.io/v2

Method HTTP request Description
deleteOrder DELETE /store/order/{orderId} Delete purchase order by ID
getInventory GET /store/inventory Returns pet inventories by status
getOrderById GET /store/order/{orderId} Find purchase order by ID
placeOrder POST /store/order Place an order for a pet

getInventory

kotlin.collections.Map<kotlin.String, kotlin.Int> getInventory()

Returns pet inventories by status

Returns a map of status codes to quantities

Example

// Import classes:
//import io.swagger.client.infrastructure.*
//import io.swagger.client.models.*

val apiInstance = StoreApi()
try {
    val result : kotlin.collections.Map<kotlin.String, kotlin.Int> = apiInstance.getInventory()
    println(result)
} catch (e: ClientException) {
    println("4xx response calling StoreApi#getInventory")
    e.printStackTrace()
} catch (e: ServerException) {
    println("5xx response calling StoreApi#getInventory")
    e.printStackTrace()
}

Parameters

This endpoint does not need any parameter.

Return type

kotlin.collections.Map<kotlin.String, kotlin.Int>

Authorization

api_key

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

This commit adds Api/Model/Auth documentation to the generated
README.md. Because auth support is not yet fully implemented (users can
manually set default headers globally), there aren't examples for helper
auth methods.

Models with inline enums document allowed values rather than pointing to
a generated enum class.

Two global additionalProperties were added (generateApiDocs,
generateModelDocs) to allow templates to conditionally display
documentatoin depending on these mutually exclusive settings. All
current generators supporting docs will attempt to link to generated
models when only api docs are specified.

This also moves the $@ bash parameter in bin/kotlin-client-petstore.sh
to the end of the args variable. This is because $@ can only be used to
pass System properties like -DdebugModels, can can already be passed as:

JAVA_OPTS="$JAVA_OPTS -DdebugModels" ./bin/kotlin-client-petstore.sh

By moving the $@ to the end of the args, it allows us to pass additional
properties and other switches directly to the script.
@jimschubert
Copy link
Copy Markdown
Contributor Author

This PR addresses a few todos from #5730

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants