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

Support @constraint annotation mapping for Ballerina to OpenAPI #5109

Closed
1 of 8 tasks
lnash94 opened this issue Jul 20, 2022 · 2 comments
Closed
1 of 8 tasks

Support @constraint annotation mapping for Ballerina to OpenAPI #5109

lnash94 opened this issue Jul 20, 2022 · 2 comments
Assignees
Labels
Area/BallerinaToOpenapi Reason/Complex Issue occurred due to complex scenario. Reason/MultipleComponentInteraction Issue occured due to interactions in multiple components. Type/Improvement

Comments

@lnash94
Copy link
Member

lnash94 commented Jul 20, 2022

  • Primitive type: Integer : (ballerina mapping) int
format keywords Ballerina Mapping
int32   int
int64   int
  minimum @constraint:Int {   minValue: <value>}
  maximum @constraint:Int {   maxValue: <value>}
  exclusiveMinimum @constraint:Int {   minValueExclusive: <value>}
  exclusiveMaximum @constraint:Int {   maxValueExclusive: <value>}
  multipleOf
  • Primitive type: float (ballerina mapping) : float
format keywords Ballerina Mapping
  minimum @constraint:Float {   minValue: <value>}
  maximum @constraint:Float {   maxValue: <value>}
  exclusiveMinimum @constraint:Float {   minValueExclusive: <value>}
  exclusiveMaximum @constraint:Float {   maxValueExclusive: <value>}
  multipleOf
  • Primitive type: Double (ballerina mapping) : decimal
format keywords Ballerina Mapping
  minimum @constraint:Number {   minValue: <value>}
  maximum @constraint:Number {   maxValue: <value>}
  exclusiveMinimum @constraint:Number {   minValueExclusive: <value>}
  exclusiveMaximum @constraint:Number {   maxValueExclusive: <value>}
  multipleOf
  • Primitive type: String (ballerina mapping) : string
format keywords Ballerina Mapping
  minLength @constraint:String {   minLength: <value>}
  maxLength @constraint:Stringl {   maxLength: <value>}
(not support from OpenAPI)  length @constraint:Stringl {   length: <value>}
  pattern
  • Array type: String (ballerina mapping) : array
format keywords Ballerina Mapping
  minItems @constraint:Array {   minLength: <value>}
  maxItems @constraint:Array {   maxLength: <value>}
  uniqueItems
  • Object type: object schema (ballerina mapping) : record type
format keywords Ballerina Mapping
  minProperties
  maxProperties
  • Apply this for object schema to record type mapping
  • Apply for type definitions
@lnash94 lnash94 changed the title Support @constraint annotation support for Ballerina to OpenAPI mapping Support @constraint annotation mapping for Ballerina to OpenAPI Jul 20, 2022
@lnash94 lnash94 self-assigned this Jul 22, 2022
@lnash94 lnash94 added the Reason/Other None of the other reasons. label Sep 28, 2022
@lnash94 lnash94 added Reason/Complex Issue occurred due to complex scenario. Reason/MultipleComponentInteraction Issue occured due to interactions in multiple components. and removed Points/2.5 Reason/Other None of the other reasons. labels Feb 2, 2023
@lnash94
Copy link
Member Author

lnash94 commented Feb 9, 2023

When implementing a fix for this issue we encountered a blocker with accessing the value in annotation fields whose types are in separate modules and third-party package. (ex: central pushed).

There are three solutions have been suggested :

  1. Change constraint annotations implementations into const and try to use semantic APIs attachment point API
  2. Improve the Semantic API for accessing the non-const annotation field value.
  3. Change the OpenAPI tool input into taking the ProjectAPI and process.

Describe your problem(s)
Among the 3 solutions passing projectAPI into the tool still has problems with

  1. accessing the annotation value which are in separate packages.
  2. It causes some API changes to the whole Ballerina to OpenAPI tool. Although we passed it there still we have done some kind of process finding dependency graphs for tracking dependencies to access the type defined in the separate package. It will cause some kind of conflict to the current util since it may additional processes to mapping. Complexity can be delayed to generate openAPI spec, resolving dependency issues, intermittent issues etc. (This util has been used in several modules http, choreo, vsCode. Therefore we required to safe method to solve this.)

@lnash94 lnash94 transferred this issue from ballerina-platform/openapi-tools Oct 31, 2023
@lnash94
Copy link
Member Author

lnash94 commented Oct 31, 2023

Close with the favour with this issue #4788

@lnash94 lnash94 closed this as completed Oct 31, 2023
@github-project-automation github-project-automation bot moved this from BackLog to Done in Ballerina Team Main Board Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area/BallerinaToOpenapi Reason/Complex Issue occurred due to complex scenario. Reason/MultipleComponentInteraction Issue occured due to interactions in multiple components. Type/Improvement
Projects
Archived in project
1 participant