Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add kotlin generator, includes schema generation and validation #431

Merged
merged 78 commits into from
May 20, 2024

Conversation

spacether
Copy link
Contributor

@spacether spacether commented May 2, 2024

Add kotlin generator

  • includes schema generation and validation
  • includes generation of openapi 303 and 310 client samples with included json schema tests that run and pass in CI

thoughts on kotlin map output class constructors vs using named args

  • usingnamed args is possible BUT
  • kwargs would have to be passed first as Pair<String, String> varargs
  • one could not type hint unions like Union[str, int] in python
  • for that reason, I choose to keep using the existing java style map + list builder
  • in the future one could add a flag createBuilderForMapOutputClasses and when it was false named arguments + varargs would be used like described above
  • or one could auto-generate an of method for the output classes if all of their args have one type only

future work

  • remove unneeded getNewInstance methods for primitive types in JsonSchema
  • simplify the JsonSchemaInfo class, used named args with defaults

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    mvn clean package 
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/generate_samples_configs/python*
    For Windows users, please run the script in Git BASH.

@spacether spacether marked this pull request as draft May 2, 2024 21:48
@spacether spacether force-pushed the feat_adds_kotlin branch 2 times, most recently from f51cd08 to 8f0c9bc Compare May 6, 2024 18:05
@spacether spacether force-pushed the feat_adds_kotlin branch 4 times, most recently from 316c239 to 0bb1891 Compare May 17, 2024 22:00
Updates UuidJsonSchema

Updates AdditionalPropertiesValidatorTest

Removes unused kotlin files in petstore

Updates the type value method interfaces and enum validators

Updates some lingering java code to kotlin

Fixes compile errors

Fixes JsonSchemaKeywordFlagsTest

Fixes JsonSchemaFactory and existing tests

FIxes CustomIsoparserTest

Updates FormatValidatorTest

Updates ItemsValidatorTest

Updates JsonSchemaTest

Updates PropertiesValidatorTest

Updates RequiredValidatorTest

Updates TypeValidatorTest

Updates AnyTypeSchemaTest

Updates ArrayTypeSchemaTest

Updates BooleanSchemaTest

Updates ListBuilderTest

Updates ListSchemaTest

Updates MapSchemaTest

Updates NullSchemaTest

Updates NumberSchemaTest

Partial updated to ObjectTypeSchemaTest kt file only

More partial updates to ObjectTypeSchemaTest kt file

Adds ObjectTypeSchemaTest

Partial update of RefBooleanSchemaTest

Updates RefBooleanSchemaTest

Stops generating api client and rest client if there are no paths in kotlin

Kotlin does not generate response sif there are not component responses or paths

Makes request body kotlin generation conditional on presence of paths or component request bodies

Conditionally generate parameters and headers packages for kotlin

303 sample regen

Conditionally generates mediatype in kotlin

Kotlin makes contenttype generation conditional

Refactors supporting file adding into one method in kotlin

Conditionally generate ApiCOnfiguration, fix artifactId warning

Conditionally generates ApiException

Makes generation of NotImplementedException conditional

Updates readme to detect no endpoints, updates readme and gradle settings to use generatorSettings

Fixes readme reference to artifactVersion

Fixes various kotlin bugs, tests now pass without generated schemas

Kotlin 303 regen, component schemas and tests deleted

Fixes object output class initialization and requiredProps and optionalProps static vars

Fixes object output class property methods

Fixes output types for kotlin

Fixes kotlin input types

Fixes of input type definitions

Removes list map and set imports

Objects import removed

Many schema generation fixes, imports property methods

Removes casts because kotlin smart casts

Many fixes for builder setter interfaces and methods

More improvements to builder setters

Fixes setters and builder classes

Fixes sealed interfaces for schemas

Updates type values

Udpates properties, moves JsonSchemaInfo higher

Partial validate fix

Adds needed schema constructors

Updates getNewInstance

Fixes broken code in validate methods

Removes PropertyEntry, more fixes

Fixes many more kotlin errors

Fixes some kotlin casting issues

Updates schema info list creation to use listOf

Updates code to use setOf

Fixes array input and output classes

Fixes schema extension of primitive json schemas

Fixes enum types

Fixes json schema enum data

Fixes defaultValue method

Fixes character escaping

Removes many unneeded semicolons

Fixes kotlin 303 tests

Kotlin 303 sample added to ci

Adds kotlin doc

Adds circleci test for kotlin

tweaks circleci file

Turns off kotlinc version printing

Checks gradle wrapper version

Updates android image

Switches image version

Changes kotlin image ot use openjdk

Removes kotlinc log

Updates wrapper invocation

Turns on test logging, forces to be rerun
@spacether spacether changed the title Add kotlin generator, json schema validation + type classes converted from java into kotlin Add kotlin generator, includes schema generation and validation May 17, 2024
@spacether spacether marked this pull request as ready for review May 19, 2024 01:26
@spacether spacether merged commit aa6e36f into master May 20, 2024
6 checks passed
@spacether spacether deleted the feat_adds_kotlin branch May 20, 2024 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant