') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); [jaxrs-spec] Add builders to models by shybovycha · Pull Request #4916 · OpenAPITools/openapi-generator · GitHub
Skip to content

[jaxrs-spec] Add builders to models - #4916

Closed
shybovycha wants to merge 5 commits into
OpenAPITools:masterfrom
shybovycha:enhancement-4.3.x/add-builders-to-models
Closed

[jaxrs-spec] Add builders to models#4916
shybovycha wants to merge 5 commits into
OpenAPITools:masterfrom
shybovycha:enhancement-4.3.x/add-builders-to-models

Conversation

@shybovycha

@shybovychashybovycha commented Jan 2, 2020

Copy link
Copy Markdown
Contributor

As per #2415, adding builders generation for models.

The reasons for this change are:

  1. currently the setters do not have the set prefix, which makes models not comply with java beans requirements
  2. constructing models becomes painful, specifically when they have numerous fields

Compare the current way to construct a model to the proposed one:

now:

new Model().property1(value1).property2(value2)
// getters/setters
myModel.getProperty1();
myModel.property1(value1);

proposed:

Model.builder().property1(value1).property2(value2).build()
// getters/setters
myModel.getProperty1();
myModel.setProperty1(value1);

PR checklist

  • Read the contribution guidelines.
  • If contributing template-only or documentation-only changes which will change sample output, build the project before.
  • Run the shell script(s) under ./bin/ (or Windows batch scripts under.\bin\windows) to update Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit, and these must match the expectations made by your contribution. You only need to run ./bin/{LANG}-petstore.sh, ./bin/openapi3/{LANG}-petstore.sh if updating the code or mustache templates for a language ({LANG}) (e.g. php, ruby, python, etc).
  • File the PR against the correct branch: master, 4.3.x, 5.0.x. Default: master.
  • Copy the technical committee to review the pull request if your PR is targeting a particular programming language.

@shybovychashybovycha changed the title Enhancement 4.3.x/add builders to modelsAdd builders to modelsJan 2, 2020
@shybovycha

Copy link
Copy Markdown
ContributorAuthor

JFYI: bitrise build is wrong - it tries to do something for swift4 with swift5-all.sh script, which apparently does not exist. Should the builds depend on the branch (e.g. swift4 for non-5.x branch and swift5 for 5.x)?

sh: bin/swift5-all.sh: No such file or directory
| |
+---+---------------------------------------------------------------+----------+
| x | Update Swift4 samples (exit code: 127) | 33.32 sec|
+---+---------------------------------------------------------------+----------+
| Issue tracker: https://github.com/bitrise-io/steps-script/issues |
| Source: https://github.com/bitrise-io/steps-script |
+---+---------------------------------------------------------------+----------+

@shybovychashybovycha changed the title Add builders to models[jaxrs-spec] Add builders to modelsJan 3, 2020
@wing328

Copy link
Copy Markdown
Member

The bitwise failure can be ignored as we just added the Swift 5 generator to the master.

Comment threadmodules/openapi-generator/src/main/resources/JavaJaxRS/spec/pojo.mustache Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that the body parameter name changes from user to body. Likely you're not using the latest (or recent) master when creating this PR.

Please merge the latest master of the official repo into your branch and regenerate the sample again.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have used 4.3.x as the origin of my branch, are you sure I should merge master in?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. Please put it on hold. I'll take another look over the weekend or next week.

@wing328wing328Jan 3, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this setting defaults to false, you can then target this change to the current master as it's no longer a breaking change. Otherwise, you will need to wait for 4.3.0 to be released on Feb 29.

@shybovycha
shybovychaforce-pushed the enhancement-4.3.x/add-builders-to-models branch from d4582ef to ccb071fCompareJanuary 5, 2020 23:47
@shybovycha
shybovycha changed the base branch from 4.3.x to masterJanuary 5, 2020 23:47
@shybovycha

Copy link
Copy Markdown
ContributorAuthor

To name the branch accordingly and restart the failing builds I'll close this PR and open a new one, with the correct target branch.

@shybovycha
shybovycha deleted the enhancement-4.3.x/add-builders-to-models branch January 5, 2020 23:51
Sign up for freeto 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.

2 participants

@shybovycha@wing328