cjbooms / fabrikt

Generates Kotlin Code from OpenApi3 Specifications
Apache License 2.0
158 stars 41 forks source link

Support generation of models from requestBodies section #20

Open cjbooms opened 3 years ago

cjbooms commented 3 years ago

Currently we only generate models from the schemas and parameters sections

Consider expanding generation to support generating models from definitions within requestBodies also

This could be as simple as this:

SchemaInfo( ...  ) {
...
        allSchemas = openApi3.schemas.entries.map { it.key to it.value }
            .plus(openApi3.parameters.entries.map { it.key to it.value.schema })
            .plus(
                openApi3.requestBodies.entries.flatMap { requestBody ->
                    requestBody.value.contentMediaTypes.map { requestBody.key to it.value.schema }
                }
            )
            .map { (key, schema) -> SchemaInfo(key, schema) }

But lots test cases are need to validate this

atollk commented 1 year ago

But lots test cases are need to validate this

Could you elaborate? Seems rather straightforward to me.

cjbooms commented 1 year ago

But lots test cases are need to validate this

Could you elaborate? Seems rather straightforward to me.

Lots is an exaggeration. It just may not be as simple as at first glance, we would need a test case to validate

Kuchteq commented 3 weeks ago

How could the commit referencing the issue be improved? I'm eager to work on it as I got the changes made there to work with the latest commit. I understand that there was something wrong with it as it got reverted.