Skip to content

Conversation

@code-lucidal58
Copy link
Contributor

@code-lucidal58 code-lucidal58 commented Dec 17, 2020

Fix logic for removal of forward slash in RegGen pattern
@spacether

@wing328
Copy link
Member

wing328 commented Dec 17, 2020

I wonder if a test can be added to cover this issue moving forward.

@code-lucidal58
Copy link
Contributor Author

I shall add tests for the same.

@wing328
Copy link
Member

wing328 commented Dec 18, 2020

Looks like this is causing issues to the python-legacy generator:


Exception in thread "main" java.lang.RuntimeException: Could not process model 'format_test'.Please make sure that your schema is correct!
--
3624 | at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:499)
3625 | at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:875)
3626 | at org.openapitools.codegen.cmd.Generate.execute(Generate.java:432)
3627 | at org.openapitools.codegen.cmd.OpenApiGeneratorCommand.run(OpenApiGeneratorCommand.java:32)
3628 | at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:66)
3629 | Caused by: java.lang.StringIndexOutOfBoundsException: begin 0, end -1, length 0
3630 | at java.base/java.lang.String.checkBoundsBeginEnd(String.java:3319)
3631 | at java.base/java.lang.String.substring(String.java:1874)
3632 | at org.openapitools.codegen.languages.PythonLegacyClientCodegen.toExampleValueRecursive(PythonLegacyClientCodegen.java:800)
3633 | at org.openapitools.codegen.languages.PythonLegacyClientCodegen.toExampleValue(PythonLegacyClientCodegen.java:718)
3634 | at org.openapitools.codegen.DefaultCodegen.fromProperty(DefaultCodegen.java:3095)
3635 | at org.openapitools.codegen.DefaultCodegen.addVars(DefaultCodegen.java:4881)
3636 | at org.openapitools.codegen.DefaultCodegen.addVars(DefaultCodegen.java:4823)
3637 | at org.openapitools.codegen.DefaultCodegen.fromModel(DefaultCodegen.java:2547)
3638 | at org.openapitools.codegen.DefaultGenerator.processModels(DefaultGenerator.java:1250)
3639 | at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:494)
3640 | ... 4 more

Can you please take a look?

@code-lucidal58
Copy link
Contributor Author

code-lucidal58 commented Dec 18, 2020

For this error, all patterns in the YAML files should start with ^ and end with $. Is it correct to make this assumption? There are some properties pattern_without_delimiter. It won't be valid anymore.
If not I can add a line to toExampleValueRecursive after the two while statements that if the pattern string is empty (meaning it never encountered ^ and $, then use the original pattern string.

@wing328
Copy link
Member

wing328 commented Dec 18, 2020

For this error, all patterns in the YAML files should start with ^ and end with $. Is it correct to make this assumption?

I don't think that's a correct assumption

@spacether
Copy link
Contributor

spacether commented Dec 18, 2020

From the spec

pattern (This string SHOULD be a valid regular expression, according to the ECMA 262 regular expression dialect)

Per there we can have valid regexes like:
b/hi/g
or /hi/g
which needs to be converted to values that RegGen can use

@code-lucidal58
Copy link
Contributor Author

Updated logic:
if regex starts with / trim it. If it ends with /i /g /m or / trim it

@spacether
Copy link
Contributor

Thank you for updating your sample spec, that looks good. Now the tests are failing. Can you take a look here and update them?

[ERROR] testGeneratedExampleValues(org.openapitools.codegen.python.PythonLegacyClientCodegenTest)  Time elapsed: 0.06 s  <<< FAILURE!
java.lang.AssertionError: expected [true] but found [false]
	at org.openapitools.codegen.python.PythonLegacyClientCodegenTest.testGeneratedExampleValues(PythonLegacyClientCodegenTest.java:108)

Closing and re-opening the PR to kick off CI again. Some of these failures were unrelated.

@spacether spacether closed this Dec 19, 2020
@spacether spacether reopened this Dec 19, 2020
@code-lucidal58
Copy link
Contributor Author

code-lucidal58 commented Dec 19, 2020

The testcases are failing in PythonLegacyTest. Need some time to fix it. Next 24hours would be enough

@wing328
Copy link
Member

wing328 commented Dec 21, 2020

@wing328 wing328 merged commit 72dc0cf into OpenAPITools:master Dec 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants