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

fix: incorrect code generation by swagger-codegen-maven-plugin #22

Closed

Conversation

terekhovmv
Copy link
Collaborator

@terekhovmv terekhovmv commented Mar 13, 2023

In case of code generation via swagger-codegen-maven-plugin there are problems with escaping some quote symbols in the sources generated. This causes compilation errors.
The following plugin settings are used for repro:

    <build>
        <plugins>
            <plugin>
                <groupId>io.swagger.codegen.v3</groupId>
                <artifactId>swagger-codegen-maven-plugin</artifactId>
                <version>3.0.41</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <inputSpec>${project.basedir}/../ewm-main-service-spec.json</inputSpec>
                            <language>spring</language>
                            <library>spring-boot</library>
                            <apiPackage>${apiPackage}</apiPackage>
                            <modelPackage>${modelPackage}</modelPackage>
                            <configOptions>
                                <sourceFolder>src/main/java/</sourceFolder>
                                <dateLibrary>java8</dateLibrary>
                                <interfaceOnly>true</interfaceOnly>
                                <useBeanValidation>true</useBeanValidation>
                                <performBeanValidation>true</performBeanValidation>
                            </configOptions>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

See the whole demo pom.xml in terekhovmv@da018e0 .

This issue is not reproduced for specs of stats service.

@algolov
Copy link
Collaborator

algolov commented Mar 14, 2023

@terekhovmv, thanks for PR!
But while the PR describes a trivial change, it raises the more important question of skill hardening.
The point is that the assignment does not imply code generation based on the specification. As part of the assignment it is important to practice the skills of creating the appropriate classes by hand, rather than by code generation tools. On a real job it is more likely that you will be given a high-level description of the task and won't have a swagger specification by which you could generate the necessary classes. These classes will have to be designed and created by yourself.
As part of the learning process, we can't give a completely unspecified assignment which assumes complete freedom of implementation. It has a lot to do with the review and testing processes. Nevertheless, it is important for us to teach students to read and understand the textual wording of the assignment.
So, from a skills perspective, we recommend not using code generation, but instead relying on the description given in the specification and creating the corresponding classes by hand.

@kpmy kpmy closed this Oct 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants