com.reprezen.genflow.openapi3.doc.TopMatter.xtend Maven / Gradle / Ivy
/*******************************************************************************
* Copyright © 2013, 2016 Modelsolv, Inc.
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains the property
* of ModelSolv, Inc. See the file license.html in the root directory of
* this project for further information.
*******************************************************************************/
package com.reprezen.genflow.openapi3.doc
import com.reprezen.kaizen.oasparser.model3.OpenApi3
class TopMatter {
extension DocHelper = HelperHelper.docHelper
def get(OpenApi3 model) {
'''
«model.info?.title» «model.baseUri»
«model.info?.description?.docHtml»
Version «model.info?.version»
Contact «model.contactInfoHtml»
Terms of Service «model.info?.termsOfService.docHtml»
License «model.licenseInfoHtml»
'''
}
// FIXME adapt to OAS3
// def private getScheme(OpenApi3 model) {
// val schemes = model.schemes.map[it.toString.toLowerCase] // OpenApi3 model api uses ugly upper-case scheme names
// for (preferredScheme : #["https", "http"]) {
// if (schemes.contains(preferredScheme)) {
// return preferredScheme
// }
// }
// if(schemes.size > 0) model.schemes.get(0) else "http"
// }
def private getBaseUri(OpenApi3 model) {
// FIXME adapt to OAS3
// '''(«model.getScheme»://«model.host»«model.basePath»)'''
}
def private getContactInfoHtml(OpenApi3 model) {
val contact = model.info?.contact
if (contact !== null) {
val primaryText = contact.name ?: contact.url
val primary = if (contact.url !== null) '''«primaryText»''' else primaryText
val email = if (contact.email !== null) '''«contact.email»'''
'''«primary» «email»'''
}
}
def private getLicenseInfoHtml(OpenApi3 model) {
val license = model.info?.license
if (license !== null) {
val text = license.name ?: license.url
if (license.url !== null) '''«text»''' else text
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy