Openapi generator enum1/13/2024 ![]() ![]() So the solution is now possible in theory, but there are several things that need to be done before it's usable in practice. It will obviously take a bit for JSON Schema vendors to add support for vocabularies (meaning, add the annotation output support and enable folks to write plugins to handle previously unknown vocabularies rather than just hardcoding all keyword support) and for OAS vendors to make use of that (meaning make use of annotations from JSON Schema to recognize codegen use cases). config-help Config help for chosen lang generate Generate code with the specified generator. batch Generate code in batch via external configs. I'm not aware of any such vocabulary, but now that OAS 3.1 is out and fully compatible with JSON Schema 2020-12, anyone (such as a tooling vendor) can create a vocabulary and work to get it supported in implementation without having to wait for a new version of OAS or JSON Schema. The most commonly used openapi-generator-cli commands are: author Utilities for authoring generators or customizing templates. Install via homebrew: brew install openapi-generator Then, generate a ruby client from a valid petstore.yaml doc: openapi-generator generate -i petstore. ![]() A more likely approach would be a code generation vocabulary of keywords rather than a single codeGen keyword which would get very overloaded very quickly. ![]() The advantage of OAS 3.1 + 2019-09 JSON Schema is that this process of producing a new vocabulary can happen independent of both the JSON Schema and OAS specification I made up codeGen: namedEnum on the spot when writing that comment. Hopefully once OAS 3.1 is out (assuming draft 2019-09 JSON Schema support is indeed included) the OpenAPI community will use the new features to try out different ideas and converge on a standard code generation vocabulary. This is just one of many ways this (and other code generation problems) could be solved. Validators can safely ignore the unknown-to-them codeGen keyword and treat the other keywords as usual for validation purposes, while code generators get the additional information they need from the specialized keyword. This way, we do not need to add more keywords that have an identical validation effect, which adds to the burden of validator implementations. Presumably, the definition of how this keyword works would say something like "the namedEnum value, when it appears alongside of a oneOf where each branch of the oneOf contains a const and a title, indicates that the oneOf should be treated as a named enumeration, where const gives the value and title gives the name." In this example, the codeGen keyword informs the generator that the Schema Object should be interpreted as a named enum. CodeGen: namedEnum oneOf: - const: 1 title: Sunny description: Blue sky - const: 2 title: Cloudy description: Slightly overcast - const: 3 title: Rainy description: Take an umbrella with you ![]()
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |